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 2005 Forums
 Transact-SQL (2005)
 Is it possible to stack 2 tables on top of each other

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2007-03-05 : 10:48:53
CWI writes "Hello

Is it possible to stack 2 tables so that the results from table one is combined with table 2

In this example
Both tables have the same fields
1st table has 200 lines
2nd table has 300 lines
combine the 2 tables results in 500 lines

Thanks"

svicky9
Posting Yak Master

232 Posts

Posted - 2007-03-05 : 10:54:04
select * from table1
union
select * from table2

The above query will remove duplicates

select * from table1
union all
select * from table2

The above query gives you all records including duplicates

Vic
Go to Top of Page
   

- Advertisement -