I have [MySp], A stored procedure.
So check this out.. when I run this it works:
SELECT ID,Name FROM Table
But, When I do this, I get an error on the application side (Adodb)
Declare @Table TABLE(ID int,Name varchar(10))
--- Inserts into table variable ---
INSERT INTO @Table
SELECT ID,Name FROM Table
--- Returns data from table variable ---
SELECT ID,Name FROM @Table
Keep in mind, in SQL Console i get the same results for [MySp], but in the application/adodb code i get errors.
ASP Code:
Set oRS = Server.CreateObject("Adodb.Recordset")
oRS.Open "[MySp]", Conn
If oRS.EOF Then... <--Gives an error
ADODB.Recordset error '800a0e78'
Operation is not allowed when the object is closed.
Does anyone know why I’m getting this error when I use Table variables in SQL?
Try adding
SET NOCOUNT ONat the top of the stored procedure.I have a vague recollection that ADO used to get confused by the result counts coming back from inserts/updates/deletes.
E.g.: