View Single Post

   
  #1 (permalink)  
Old 02-28-2008, 05:39 PM
Robert Brown
 
Posts: n/a
Default Newbie Question: Can you have multiple Select Statements in a stored proc that interrelate

Hi All.

I have been writing simple single stored procedures for a few years
now, but a client needs some reports (under Crystal) that I seem to
think the only way to get the data (from SQL2000) is to build up a
results set using a stored procedure with multiple select statements,
interrelated.

What I mean is this..

I have a Select statement that gathers information from one table.
Lets say 5 fields.

Then, the next select statement uses those two of those five fields to
get more data (lets say 15 fields), which then I have to join with the
data from the first select statement based on the result.

Then, I have another select statement after that, that uses 2 fields
from the second select statement on the 1st and 2nd statement results.

The last step is to pass this all back to either the Crystal reports
or to a vb.aspx application (which I know how to call the stored
procedure from these two apps).

Now, I know it is a big ask, but is there some website, or good
documentation on how to do this (or similar)? I am trying to do too
much with the stored procedure? If you know how to do this, could you
give an example...

Thanks,
Robert
Reply With Quote