SQL Server 2005: Cursor Example

DECLARE @id INT
DECLARE db_cursor CURSOR FOR
SELECT id From myTable
OPEN db_cursor
FETCH NEXT FROM db_cursor INTO @id

WHILE @@FETCH_STATUS = 0
BEGIN
-- do something
FETCH NEXT FROM db_cursor INTO @id
END

CLOSE db_cursor
DEALLOCATE db_cursor

I have a terrible time remembering SQL syntax.

1 comments:

Anonymous said...

deareeFrage
rbeg