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 2000 Forums
 Transact-SQL (2000)
 Union all

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-10-21 : 08:01:42
Augustus Sundar writes "I have a stored procedure, Which returns a resultset in the first part

then it execute another stored procedure which returns another resultset

i want to combine both resultsets into one.

both resultsets having same set of columns,


my code is below:
-----------------
create proc testproc
as
select EmployeeId, EmpName from employees
union all
Exec testproc2



create proc testproc2
as
select EmployeeId, EmpName from employees2


But it gives an error in the proc testproc

The reason why i am keeping the testproc2 seperately that it is being used for some other purpose too.

Can anyone help me out?"

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-10-21 : 08:06:03
You need to create a temp table #t with same number of columns that sp returns and assign values there

Create #t table(cols...........)

Insert into #t Exec testproc
Go
Insert into #t Exec testproc2

Now #t will have records from those two sps


Madhivanan

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

- Advertisement -