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
 General SQL Server Forums
 New to SQL Server Programming
 insert

Author  Topic 

peace
Constraint Violating Yak Guru

420 Posts

Posted - 2012-07-03 : 02:24:48
how to insert into a tableA from another tableB which doesn't exist in tableA?

ahmeds08
Aged Yak Warrior

737 Posts

Posted - 2012-07-03 : 02:32:45
if the table structure of both the tables is same then you can use

insert into tablea select * from tableb
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2012-07-03 : 06:13:51
insert into tableA(cols)
select cols from tableB as B where not exists(select * from tableA where A.keycol=B.keycol)

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -