I need to insert values from a table into a sproc. For example:
exec mysproc @param1='col1', @param2='col2'
This can be done using a cursor but is there some way to do it via a set operation?
I need to insert values from a table into a sproc. For example:
exec mysproc @param1='col1', @param2='col2'
This can be done using a cursor but is there some way to do it via a set operation?
I imagine that the method you choose would be based on the amount of time you have available and it's difficult to say which of these methods is most time consuming without being more intimate with the logic.
There are a few approaches to this problem.
SELECT Moo, Meow
FROM Woof
WHERE Fu = @ParmX
AND Bar = @ParmY
Your proc should be called with @ParmX, @ParmY
and the logic inside would then proceed in a set based manner.
It is not possible to invoke an sproc as part of a "set operation". Probably, the reason for that is that the sproc might have arbitrary side-effects like modifying data, sending additional result sets (!) or shutting down the server.
A cursor is the canonical approach to this. (Alas.)
You could modify the sproc to take a TVP, of course. Not sure if that is workable for you.