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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Execute A Stored Procedures from a Query

Status
Not open for further replies.

JVZ

Programmer
Sep 3, 2002
205
0
0
CA
Hello All -

I was wondering if the below query is possible?

SELECT tDate, rCount
FROM (EXEC usp_someSP)
GROUP BY tDate



 
Unfortunately, not possible.

But if you could combine the logic of the query alone with the stored procedure to make another stored procedure is also not a bad idea.
 
You can insert the result set of a stored proc into a temporary table. Then select from the table.

Create Table #temp(Tdate datetime, rCount int)

INSERT #temp
EXEC usp_someSP

SELECT tDate, Tot=Sum(rCount)
FROM #temp
GROUP BY tDate

Drop Table #temp

If you want to get the best answer for your question read faq183-874 and faq183-3179.
Terry L. Broadbent - DBA
SQL Server Page:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top