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 2008 Forums
 Transact-SQL (2008)
 Combine multiple record sets of multiple procedure

Author  Topic 

Jawad
Starting Member

17 Posts

Posted - 2011-11-14 : 07:40:56

Hi

SQLServer version 2005/2008
One of my store procedure call multiple store procedures as follows:

begin
exec StoreProcedure1
exec StoreProcedure2
exec StoreProcedure3
end

and every called store procedure return a single record in a separate record set, so I got multiple resultant record sets of single values I want to combine and display all these values in single record set.
Please guide me how can I combine all of my single value record sets in one record set.

Wishes
J a w a d

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-11-14 : 07:42:49
are all those recordsets having same fields? then you can create a temporary table with structure same as recordset and then do like

...
insert #temp
exec StoreProcedure1

insert #temp
exec StoreProcedure2

insert #temp
exec StoreProcedure3
....


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

Jawad
Starting Member

17 Posts

Posted - 2011-11-15 : 10:51:05
Thanks visakh16

Its simple and great solution, will it also work with @Table variable as well?

Wishes
J a w a d

quote:
Originally posted by visakh16

are all those recordsets having same fields? then you can create a temporary table with structure same as recordset and then do like

...
insert #temp
exec StoreProcedure1

insert #temp
exec StoreProcedure2

insert #temp
exec StoreProcedure3
....


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/



Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-11-15 : 11:01:47
it will from sql 2005 onwards

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -