Skip to content

Instantly share code, notes, and snippets.

@tjklemz
Created February 16, 2015 03:36
Show Gist options
  • Save tjklemz/f9a5ef72c6d4c3d81b2d to your computer and use it in GitHub Desktop.
Save tjklemz/f9a5ef72c6d4c3d81b2d to your computer and use it in GitHub Desktop.
DECLARE Id INT, @Title VARCHAR(50)
DECLARE Iterator CURSOR FORWARD_ONLY FOR
SELECT Id, Title FROM dbo.SourceTable
OPEN Iterator
WHILE 1=1 BEGIN
FETCH NEXT FROM @InputTable INTO @Id, @Title
IF @@FETCH_STATUS < 0 BREAK
PRINT 'Do something with ' + @Title
END
CLOSE Iterator
DEALLOCATE Iterator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment