[dba-SQLServer] Return the result set of a sproc additively

Arthur Fuller fuller.artful at gmail.com
Tue Sep 16 09:43:38 CDT 2008


I'm having a senior moment, but I know I have done this, and I think I have
written about how to do it, but I can't find the article and can't remember
how to do it, but I do know it can be done.

Here's the gist.

I want to call a sproc (which is just a select) N times and have the result
sets "unioned", as it were. Say for example we have 5 salespersons in a
company, and I want the sales of 4 of them. It's easy to grab the 4 selected
IDs, but then I want to go in and grab all the sales for those 4. This is
the important part: I don't want to rewrite the logic that's already there
to grab one salesperson's data. I want to call that sproc several times and
union the results.

I'm sure that I have done this but at the moment I can't remember how I did
it.

TIA,
Arthur



More information about the dba-SQLServer mailing list