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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 RESULT SET

Author  Topic 

WoodHouse
Posting Yak Master

211 Posts

Posted - 2009-07-30 : 08:50:04
Hi


Combine three different Stored Procedures in one result set

I have one procedure “ProcedureA”. I am calling this procedure in PROCB
When I run PROCB It will return three result sets. Bcoz each ProcedureA will return col1, col2, col3. So I wan to combine the those result set.

ProcedureA Col1

ProcedureA Col2

ProcedureA Col3

I want like this. …without using temp table or union

COL1, COL2, COL3

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-07-30 : 08:52:37
ProcedureA return the result via the OUTPUT parameter or a result set ? The result set is single column, single row ?


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

WoodHouse
Posting Yak Master

211 Posts

Posted - 2009-07-30 : 08:55:08
Hi

It's result set it's ....return single column but multiple rows...
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-07-30 : 08:59:33
[code]
create table #t1 (id int identity, col1 int)
create table #t2 (id int identity, col2 int)
create table #t3 (id int identity, col3 int)

insert into #t1 (col1) exec ProcedureA
insert into #t2 (col2) exec ProcedureA
insert into #t3 (col3) exec ProcedureA

select t1.col1, t2.col2, t3.col3
from #t1 t1
inner join #t2 t2 on t1.id = t2.id
inner join #t3 t3 on t1.id = t3.id
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

WoodHouse
Posting Yak Master

211 Posts

Posted - 2009-07-30 : 09:02:54
Hi

thanks.....but without using #temp ...is possible...?
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-07-30 : 09:05:20
No. Can't


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-07-30 : 09:38:17
Try method 2
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 -