Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 ghost rows

Author  Topic 

javaisok
Starting Member

11 Posts

Posted - 2003-10-15 : 08:14:38
does cursor populates empty rows into the response recordset when select
statements has not found any records?

declare cr_test cursor local read_only
for select id from dbo.test where bla...
open cr_test
fetch next from cr_test into @id
while @@fetch_status = 0 begin
fetch next from cr_test into @id
end
close cr_test
deallocate cr_test

this statement is being executed inside of recursive procedure and every time when there are no records found i receive one more ghost row into the response. In some iteration there are some records found but they are placed at the end of response so it looks like this:

ghost row
ghost row
ghost row
ID
---------------
1
2
3
...

why this happends? The client software says they are no records inside!

robvolk
Most Valuable Yak

15732 Posts

Posted - 2003-10-15 : 08:22:57
Please don't cross post:

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=29840
Go to Top of Page

javaisok
Starting Member

11 Posts

Posted - 2003-10-17 : 03:22:59
... i just found the problem. It seems SQL server generates recordset for
each select statement from the body of stored procedure. Then the final recordset consists n recordsets and they are all closed. only the last one is open with rows inside. funny :)))
Go to Top of Page
   

- Advertisement -