I have a stored procedure that accepts three parameters.
Is it possible to call this stored procedure with a query as input?
As an example, I have tableA.
SELECT * FROM TABLEA
| A | B | C |
|---+---+---|
| 1 | 2 | 3 |
| 4 | 5 | 6 |
Now, is there a way that I can call
EXEC sp_name (SELECT * FROM TABLEA)
so that the stored procedure will execute for each row?
My reasoning behind this is I have a stored procedure that needs to be called for multiple rows. I can write a script to do this, but want to know if its possible to do it with TSQL.
The best way to accomplish this is to create your 2nd stored procedure as a user-defined function instead. Then you can call it in this way:
Or, there may be a way to combine both stored procedures into one set, but I’d have to see what was in the 2nd one you are calling.