Created
July 8, 2015 15:21
-
-
Save jbnv/fb13ab2396c559ced87f to your computer and use it in GitHub Desktop.
SQL Server Query Cursor Pattern
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 @tblName sysname | |
DECLARE @tblId INT | |
DECLARE @sql VARCHAR(MAX) | |
DECLARE cTable CURSOR FOR | |
SELECT [sql] | |
OPEN cTable | |
FETCH NEXT FROM cTable | |
INTO @sql | |
WHILE @@FETCH_STATUS = 0 | |
BEGIN | |
PRINT @sql | |
FETCH NEXT FROM cTable INTO @tblName,@tblID | |
END | |
CLOSE cTable | |
DEALLOCATE cTable |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment