-2147217900 -- [Microsoft][ODBC
SQL Server Driver][SQL Server]Invalid
column name 'Column'.
column name 'Column'.
Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.
View products that this article applies to.
DROP PROC sptest
go
CREATE PROC sptest as
EXEC('SELECT au_id, au_lname, au_fname = (
CASE
when au_lname = "Ringer" then "value1"
else "default"
END
)
FROM Authors')
DROP PROC sptest
go
CREATE PROC sptest as
EXEC('SELECT au_id, au_lname, au_fname = (
CASE
when au_lname = ''Ringer'' then ''value1''
else ''default''
END
)
FROM Authors')
DROP PROC sptest
go
CREATE PROC sptest as
EXEC('SELECT au_id, au_lname, au_fname = (
CASE
when au_lname = "Ringer" then "value1"
else "default"
END
)
FROM Authors')
Private Sub Command1_Click()
Const CONNECTSTR = "Provider=MSDASQL.1;Persist Security Info=False;" _
& "Extended Properties=Driver={SQL Server}; " _
& "SERVER=(local);UID=<username>;DATABASE=pubs"
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim cmd As ADODB.Command
Set rs = New ADODB.Recordset
Set cn = New ADODB.Connection
With cn
.ConnectionString = CONNECTSTR
.CursorLocation = adUseServer
.Open
End With
' Uncomment this line to avoid error.
' cn.Execute "SET QUOTED_IDENTIFIER OFF"
Set cmd = New ADODB.Command
With cmd
.CommandText = "sptest"
.CommandType = adCmdStoredProc
.ActiveConnection = cn
End With
Set rs = cmd.Execute
Do Until rs.EOF
sz = ""
For i = 0 To rs.Fields.Count - 1
sz = sz & rs(i).Value & " | "
Next i
Debug.Print sz
rs.MoveNext
Loop
End Sub
Keywords: KB222664, kbstoredproc, kbprb, kbdatabase