Skip to content

Instantly share code, notes, and snippets.

@mdnmdn
Created March 16, 2012 12:01
Show Gist options
  • Save mdnmdn/2049776 to your computer and use it in GitHub Desktop.
Save mdnmdn/2049776 to your computer and use it in GitHub Desktop.
TSQL Cursor definition
DECLARE @_id int
DECLARE CUR CURSOR FOR
select id from table_name
OPEN CUR;
FETCH NEXT FROM CUR into @_id;
WHILE @@FETCH_STATUS = 0
BEGIN
PRINT cast(@_id as varchar)
FETCH NEXT FROM CUR into @_id;
END
CLOSE CUR
DEALLOCATE CUR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment