SQL Research

Created By: bravesirandrew
Last Modified: 04/18/07
note - Wed, 18 Apr 2007 13:30:36 GMT
Unions
Performing a set union is trivial in Transact-SQL thanks to the inclusion of the UNION keyword. Here's some sample code that combines two sets using the UNION operator:
CREATE TABLE #set1 (col1 int, col2 int) CREATE TABLE #set2 (col3 int, col4 int) INSERT #set1 VALUES (1,1) INSERT #set1 VALUES (2,2) INSERT #set1 VALUES (3,3) INSERT #set1 VALUES (4,4) INSERT #set1 VALUES (5,5) INSERT #set2 VALUES (1,1) INSERT #set2 VALUES (2,2) INSERT #set2 VALUES (5,5) SELECT * FROM #set1 UNION SELECT * FROM #set2 col1 col2
From:
http://innerworkings.safaribooksonline.com/0201615762/ch11

