Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stored Procedure to return results from multiple queries

Status
Not open for further replies.

TonyBoex

Programmer
Apr 11, 2001
9
US
Is there a way to have a stored procedure return the results of approximately 50 queries as a single recordset? Each query returns the number of records matching a particular parameter and I need the results of 50 queries to populate a results table on an ASP page. The individual queries are all similar to the following:

SELECT COUNT(MishapID) AS CRW --CRW is the variable string
FROM dbo.tblMishaps
WHERE (MishapID IN
(SELECT DISTINCT tblMishaps.MishapID
FROM tblMishaps, tblFactors, tblMishapFactors
WHERE tblMishaps.MishapID = tblMishapFactors.MishapID_FK
AND
tblFactors.[3rdLevelCode] = tblMishapFactors.[3rdLevelCode_FK]
AND (tblFactors.[2ndLevelCode] = 'CRW')))

How do I return all the results to the calling ASP page, individually or as a combined recordset?
 
use union
select* from xxx
union
select* from yyy John Fill
1c.bmp


ivfmd@mail.md
 
I tried using UNION but the result was a single column recordset. If possible I'd like to return a single record having 50 columns, each having a column name which corresponds to the text string criteria (ie. CRW). Thanks for the help.
 
you want to do some thing like a crosstab query? John Fill
1c.bmp


ivfmd@mail.md
 
I'll read up on Crosstab queries. Thanks for the suggestion.
 
As far as I know SQL Server doesn't support crosstab queries like access. You can do some work around. John Fill
1c.bmp


ivfmd@mail.md
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top