Created
November 18, 2014 19:27
-
-
Save billinkc/5f6411e45d9137a50fe2 to your computer and use it in GitHub Desktop.
Q&D cursor sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DECLARE test_cursor CURSOR | |
READ_ONLY | |
FOR SELECT TOP 10 | |
SV.name | |
FROM | |
master.dbo.spt_values AS SV; | |
DECLARE @name nvarchar(35) | |
OPEN test_cursor | |
FETCH NEXT FROM test_cursor INTO @name | |
WHILE (@@fetch_status = 0) | |
BEGIN | |
PRINT @@FETCH_STATUS | |
DECLARE @message nvarchar(100) | |
SELECT @message = N'my name is: ' + @name | |
PRINT @message | |
FETCH NEXT FROM test_cursor INTO @name | |
END | |
CLOSE test_cursor | |
DEALLOCATE test_cursor | |
GO | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment