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)
 merging 2 stored procedure result

Author  Topic 

imughal
Posting Yak Master

192 Posts

Posted - 2004-07-16 : 03:13:58
hi,

i have 2 separate stored procedure with same resultant fields. i wnat to merge both procedure result.

Store procedure 1 fields
clinetid, process date, un process date, noof months

Store procedure 2 fields
clinetid, process date, un process date, noof months

but the result set is different. i need to show only record which are in stored procedure 2 and remove rec which already are in store procedure 1 and 2.

how i can merge data on condition, any help will be appreciated.

regards,
IM

rockmoose
SQL Natt Alfen

3279 Posts

Posted - 2004-07-16 : 11:12:01
Create 2 temporary tables
create table #t1( ... )
create table #t2( ... )

insert #t1 exec proc1
insert #t2 exec proc2

select * from #t1 union select * from #t2

or maybe like this ( no temp tables... )

SELECT * FROM OPENROWSET('SQLOLEDB','ServerName';'UserName';'Password','exec pubs.dbo.p1') AS a
UNION
SELECT * FROM OPENROWSET('SQLOLEDB','ServerName';'UserName';'Password','exec pubs.dbo.p1') AS b


SELECT * FROM OPENROWSET('SQLOLEDB','server=sirius;Trusted_Connection=yes','exec pubs.dbo.p1')
UNION
SELECT * FROM OPENROWSET('SQLOLEDB','server=sirius;Trusted_Connection=yes','exec pubs.dbo.p2')

/rockmoose
Go to Top of Page
   

- Advertisement -