Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 using Stored Procedure records

Author  Topic 

tiss0183
Starting Member

18 Posts

Posted - 2008-06-02 : 17:43:54
How can I use the data returned from a stored procedure within another stored procedure?

For example, I trying to something along these lines:
select * from tbl_Test
union all
select * from (exec sp_Test)

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-06-03 : 00:03:23
Put the results of sp into a temporary table

CREATE TABLE #temp
(fields same as resultset of sp)

INSERT #temp
EXEC sp_Test

then use it in UNION ALL

select * from tbl_Test
union all
select * from #Temp

Make sure sp_test returns the same number of columns and have same datatype as fields of tbl_Test
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-06-04 : 11:43:09
or

http://sqlblogcasts.com/blogs/madhivanan/archive/2007/11/26/select-columns-from-exec-procedure-name-is-this-possible.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -