General information
Forum:
Microsoft SQL Server
>Hi!
>
>How can I implement a For... Next in SQL?
>
>Thanks
DECLARE myCursor CURSOR FOR SELECT {your select statement}
OPEN myCursor
FETCH NEXT FROM myCursor INTO @myVar1, @myVar2,...
WHILE @@FETCH_STATUS = 0
BEGIN
{do something here}
FETCH NEXT FROM myCursor INTO @myVar1, @myVar2,...
END
CLOSE myCursor
DEALLOCATE myCursor
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only