Skip to content

Instantly share code, notes, and snippets.

@williamsjj
Created December 1, 2009 18:59
Show Gist options
  • Select an option

  • Save williamsjj/246532 to your computer and use it in GitHub Desktop.

Select an option

Save williamsjj/246532 to your computer and use it in GitHub Desktop.
Declare firstQuery Cursor for
SELECT [id]
FROM TableName
for Read Only;
Declare @myid int;
Open firstQuery;
Fetch Next from firstQuery Into @myid;
WHILE (@@fetch_status <> -1)
BEGIN
EXEC myStoredProc @param1 = @myid;
Fetch Next from cspid Into @myspid;
END;
close firstQuery;
deAllocate firstQuery;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment