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.
| Author |
Topic |
|
OldMySQLUser
Constraint Violating Yak Guru
301 Posts |
Posted - 2008-02-08 : 08:25:15
|
| I have two tables, each containing the same columns: one containing 1000 rows and one with 800 rows. How can I create a third table which is a merge of the other two and ensuring there are no duplicates please? |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-02-08 : 08:38:53
|
| select columns from table1union select columns from table2MadhivananFailing to plan is Planning to fail |
 |
|
|
sunil
Constraint Violating Yak Guru
282 Posts |
Posted - 2008-02-08 : 08:39:19
|
| Insert into table3 select * from table1 union select * from table2 |
 |
|
|
OldMySQLUser
Constraint Violating Yak Guru
301 Posts |
Posted - 2008-02-08 : 08:42:39
|
| Thank you! |
 |
|
|
OldMySQLUser
Constraint Violating Yak Guru
301 Posts |
Posted - 2008-02-08 : 09:33:46
|
| Would this also be correct, if I had more than one table?example:Insert into table3select * from table1unionselect * from table2select * from table4select * from table5 |
 |
|
|
Qualis
Posting Yak Master
145 Posts |
Posted - 2008-02-08 : 09:58:43
|
| You need a union between each table. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-02-08 : 12:55:06
|
| If you are sure you dont have same records repeated in more than one table (duplicates) you can use union all in place of union. it will be faster as it wont look for distinct value of records |
 |
|
|
|
|
|