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)
 Insert rows from one table to the other

Author  Topic 

Exir
Posting Yak Master

151 Posts

Posted - 2010-01-27 : 05:35:58
Hi
How can i insert rows from table1 to table2 which exists in table1 and not exists in table2 ?

Kristen
Test

22859 Posts

Posted - 2010-01-27 : 05:55:15
[code]INSERT INTO Table2(Col1, Col2, ...)
SELECT Col1, Col2, ...
FROM Table1 AS T1
WHERE NOT EXISTS (SELECT * FROM Table2 AS T2 WHERE T2.SomeID = T1.SomeID)
[/code]
Go to Top of Page
   

- Advertisement -