Click to See Complete Forum and Search --> : Cursor


aneeshjohn
June 12th, 2006, 04:53 AM
hi,
i want to know how to create a cursor in SQL SERVER 2000 and print result on the screen.

Alsvha
June 12th, 2006, 05:07 AM
A way to create a cursor:

DECLARE myCursor CURSOR
FOR
SELECT value FROM table
OPEN myCursor

FETCH NEXT FROM myCursor INTO @myValue
WHILE (@@FETCH_STATUS = 0 ) BEGIN
--DoStuff
FETCH NEXT FROM myCursor INTO @myValue
END

Otherwise, check the documentation/help for SQL Server 2000. It provides pretty much the entier code you need to create/use a cursor.

aneeshjohn
June 12th, 2006, 05:17 AM
hey thanks....