Saturday, November 14, 2009

Using cursor

DECLARE Cur CURSOR FOR
SELECT AccountID, AccountName
FROM Account

OPEN Cur
FETCH FROM Cur
INTO @AccountID, @AccountName

WHILE @@FETCH_STATUS = 0
BEGIN
--Do your tasks here
FETCH FROM Cur
INTO @AccountID, @AcountName
END

CLOSE Cur
DEALLOCATE Cur

No comments:

Post a Comment