Link to home
Start Free TrialLog in
Avatar of whorsfall
whorsfallFlag for Australia

asked on

SQL exexute store procedure with results of a query.

Hi,

How can I execute a store procedure with the results of a sql query. Here is my attempt that I only got half way with.

In the example below I want to take the AssigmentID and execute each value returned to call a stored procedure.

In this example the ids that would return from the first select are:

id
16777359
16777357
16777361
16777358
16777360

Thanks,

ward.


declare @test table (id int);

insert into @test select AssignmentID from CI_CIAssignments

select * from @test

exec spUpdateAppDeploymentSummaryByCollection @AssignmentID = 16777359
exec spUpdateAppDeploymentSummaryByCollection @AssignmentID = 16777357
exec spUpdateAppDeploymentSummaryByCollection @AssignmentID = 16777361
exec spUpdateAppDeploymentSummaryByCollection @AssignmentID = 16777358
exec spUpdateAppDeploymentSummaryByCollection @AssignmentID = 16777360

Open in new window

SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Can you change the spUpdateAppDeploymentSummaryByCollection to receive a table instead of a value? That way you can send all values one time only so it will perform it all in one single step.

You can also post here the code of that Stored Procedure so we can find an alternative way to do this.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial