I have a t-sql user-defined-sp (call it sp1) which gets userId as param and return
I want to create a new user-defined-sp (call it sp2) that gets a list of userIds.
sp2 executes sp1 for each userId and union all output to one big output.
Each set of outputs for userId=a will be consecutive in the big table
i.e. the big table can look like:
a result1,1
a result1,2
a result1,3
b result2,1
b result2,1
how can I do this?
Inside the main stored proc (sp2), you can create a table variable, and populate it with the data, then select all from that table variable. Something like this:
The only thing to watch out for is that
INSERT EXECwill fail if sp2 is nested inside of another stored proc.