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
 Transact-SQL (2000)
 Simple cursor questions

Author  Topic 

gamaz2
Starting Member

31 Posts

Posted - 2008-07-08 : 16:50:43
Hi,
I am running this simple cursor (testing). However the last row is a blank that is being returned. I am not sure why. Also when I am running this code again in the EM I am not getting any result set. It only states that command successfully executed. Any help is apreciated. Thanks
CODE:
declare authors_cursor cursor
for select * from authors
open authors_cursor

While (@@fetch_status = 0)
fetch next from authors_cursor

close authors_cursor
deallocate authors_cursor

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-07-08 : 18:45:51
What are you trying to do with your query here ? Your query is doing nothing except open the cursor, loop through all records and close the cursor.



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

gamaz2
Starting Member

31 Posts

Posted - 2008-07-08 : 19:17:47
I need to display all the records from the authors table using this simple cursor. Thanks.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-07-08 : 19:28:41
take a look at the books online on cursor http://msdn.microsoft.com/en-us/library/ms180169.aspx
there are example there.

Also see this http://www.sqlteam.com/article/cursors-an-overview


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

gamaz2
Starting Member

31 Posts

Posted - 2008-07-08 : 19:52:58
Thanks for the links. I am pretty new to cursor. Regards.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-07-09 : 00:53:51
Were you just learning cursors?There's absolutely no need for cursor to just select records from a table.
Go to Top of Page

gamaz2
Starting Member

31 Posts

Posted - 2008-07-09 : 17:59:57
That is correct. I am in the process of learning cursor. Thanks.
Go to Top of Page
   

- Advertisement -