Contatinating 2 tables

How do I concatenate two tables, identical in structure, into one table?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Richard QuadlingSenior Software DeveloperCommented:
insert into table1 select * from table2

would do the trick initially.

but watch out for constraints on table1 which limit duplicate keys.
Richard QuadlingSenior Software DeveloperCommented:
If you want to make a third table, ...

insert into table3 select * from table1 union all select * from table2

should work. You would need to create table3 first.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Create a temp taable
Union the results from two tables and insert in temp table

i don't (and i don't think  the others do either) understand what you mean by concatenate two tables together....,

do you want the whole set?    UNION ALL
do you want the unique set?  UNION
do you want to Update the rows with the same key using some business logic?

 which version of SQL Server are you using?

please explain in more detail what you are attempting to achieve and the key structure of the tables and the data (unique/non unique ...) dynamics involved..

     Please do specify clearly what excatly is your requirement
 1. Do you wan your data to be combined and put in it a new table?
          insert into <New Table> select * from table1 union all select * from table2 -- replace the tagged portion with your new table name.
2.  Do you wish to insert all the records in Table2 into Table1?
     Insert into Table1 select * from Table2 -- If duplicate records are there in both the tables and you have primary key defined, then this will give you error.
3. Do you wish to create a third table and then insert all the values from Table1 and Table2 go with this.
    Create Table3 with the same structure as Table1 or Table2
    Insert into Table3 select * from Table1 union all select * from Table2
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.