Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Server 2000 Curser

Status
Not open for further replies.

gophertee

Programmer
Oct 11, 2000
27
US
Does anyone have an example of a Microsoft Sql Server 2000 Cursor, I am looking all over the internet, and am unable to find one, I need the syntax, I have one in oracle, but not for Sql Server.
 
I am looking to Create a cursor, Open it, Fetch it, and Close it. I have a complicated report that is created in two queries, I have a blank table, that I wanted to update with the Cursors.
 
here's some (very general) sample code:

declare @myid int
declare mycursor cursor for

select myid
from table1

open mycursor
fetch next from mycursor into @myid
while @@fetch_status = 0
begin
<do stuff>
fetch next from mycursor into @myid
end

close mycursor
deallocate mycursor
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top