Hi,
I'm looking for a way to loop on a set of temporary results and run a stored procedure on each row of the results.
Simplified code of what I'm trying to do:
[code=sql]
Declare @TMP TABLE
(
field1 Int
field2 Int
)
INSERT INTO @TMP
SELECT id, otherVar
from ....blah join blah join blah
where bar = foo
Declare @RC = int
-- Want to loop here.
For each result.
Exec @RC = [Process].[dbo].[usp.storedProc1] **field1** **field2**
End for
[/code]
What is the syntax to do this? Also is this terminology correct, or is there another specific word for what I'm looking for?
I'm looking for a way to loop on a set of temporary results and run a stored procedure on each row of the results.
Simplified code of what I'm trying to do:
[code=sql]
Declare @TMP TABLE
(
field1 Int
field2 Int
)
INSERT INTO @TMP
SELECT id, otherVar
from ....blah join blah join blah
where bar = foo
Declare @RC = int
-- Want to loop here.
For each result.
Exec @RC = [Process].[dbo].[usp.storedProc1] **field1** **field2**
End for
[/code]
What is the syntax to do this? Also is this terminology correct, or is there another specific word for what I'm looking for?
Comment