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.
Author |
Topic |
rcr69er
Constraint Violating Yak Guru
327 Posts |
Posted - 2008-05-30 : 04:29:00
|
Hi GuysIs it possible to perform a Union between seperate stored procedures within one stored procedure?For example:I have the following procedure:CREATE PROCEDURE [getMonthlyBreakdown](@Period DATETIME)ASEXEC [getTotalNumberOfIndividualOrders] @PeriodEXEC [getCountOfOrderLine] @PeriodEXEC [getCountOfDespatchedItems] @PeriodGODECLARE @Period DATETIMESET @Period = '2008-04-01'EXEC [getMonthlyBreakdown] @PeriodIs it possible to perform a union within the stored procedure with 3 stored procedures being called? All 3 have the same number of output rows.Thanks |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-05-30 : 05:17:02
|
Yup you can place the results of three SPs into temporary tables and take union among them. |
|
|
rcr69er
Constraint Violating Yak Guru
327 Posts |
Posted - 2008-05-30 : 05:33:13
|
HiThanks, but how would you do that? |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-05-30 : 05:47:49
|
using INSERT #TableEXEC SPName paramvaluelist... |
|
|
ganeshkumar08
Posting Yak Master
187 Posts |
Posted - 2008-05-30 : 05:59:54
|
Hello,Look into this small example code.....create proc sampleasdeclare @tab table(col1 int,col2 int)insert into @tab(col1,col2)select 1,2 unionselect 2,3 unionselect 3,4select * from @TabGodeclare @tab1 table(col1 int,col2 int)insert into @Tab1exec sampleUsing the above example you can get entire SP result into a Temporary table, After that you can join easily...Ganesh |
|
|
|
|
|