Skip to content

Instantly share code, notes, and snippets.

@afreeland
Created July 24, 2013 19:35
Show Gist options
  • Save afreeland/6073754 to your computer and use it in GitHub Desktop.
Save afreeland/6073754 to your computer and use it in GitHub Desktop.
SQL: Iterate through SQL results and execute Stored Procedure
DECLARE @aid char(11)
SELECT @aid = min(AccountID) from [Security].[Role]
WHILE @aid is not null
BEGIN
exec dbo.FillRoleControlsByAccount @aid
print 'AccountID: ' + @aid + ' has been inflated!'
select @aid = min(AccountID) from [Security].[Role] where AccountID > @aid
END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment