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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

write a cursor

Status
Not open for further replies.

cazeno

Technical User
Jun 30, 2000
23
DE
hehi<br><br>does somebody know a website where there are examples for cursor programming in sql server 6.5???<br>its urgend...i didnt found something<br><br>thx in advance<br><br>cazeno
 
Hi,<br><br>what kind of cursor do u want to write.<br><br>the general structure for the cursor is<br><br>CREATE &lt;cursorname&gt; CURSOR FOR<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;your select query&gt;<br><br>OPEN &lt;cursorname&gt;<br>FETCH FIRST FROM &lt;cursorname&gt; INTO &lt;field list specefied in the select query&gt;<br><br>WHILE @@FETCH_STAUS &lt;&gt; -1 /* For checking that you have not crossed the end of the cursor*/<br>BEGIN<br>&nbsp;&nbsp;&nbsp;&nbsp;/* your processing based on the rows given by the sever*/<br><br>&nbsp;&nbsp;FETCH NEXT FROM &lt;cursorname&gt; INTO &lt;field list specefied in the select query&gt;<br>END<br>CLOSE &lt;cursorname&gt;<br>DEALLOCATE &lt;cursorname&gt;<br><br><br>Hope this helps.<br><br><br>Nikhil<br>(<A HREF="mailto:nikhilmehrotra@mailmetoday.com">nikhilmehrotra@mailmetoday.com</A>)<br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top