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)
 Adding two result sets

Author  Topic 

developer00x
Starting Member

1 Post

Posted - 2006-09-01 : 15:15:35
Hi,

I was wondering how to add two result sets of a SELECT statement to each other
ex.

result set 1
------------
ID | Name | Balance
1 | Stan Winston | 100,000
2 | James Cameron | 200,000
3 | Nicholas Cage | 250,000

result set 2
------------
ID | Name | Balance
1 | Stan Winston | 300,000
2 | James Cameron | 500,000


The desired output should be like this:

ID | Name | Balance
1 | Stan Winston | 100,000
2 | James Cameron | 200,000
3 | Nicholas Cage | 250,000
1 | Stan Winston | 300,000
2 | James Cameron | 500,000


Thank you in advance ..

Sitka
Aged Yak Warrior

571 Posts

Posted - 2006-09-01 : 15:31:40
SELECT (ID, Name, Balance) FROM Table1 -- this is result set 1
UNION ALL
SELECT (ID, Name, Balance) FROM Table2 -- this is result set 2

"it's definitely useless and maybe harmful".
Go to Top of Page
   

- Advertisement -