Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
HII need to update table1 with new entries and updates from table2Table 1 and table 2 are both exactly the same design.Do I need to do an Insert and an update query?E.g. Insert into Table1Select * from Table2Where table2.uniqueid not in (select uniqueid form table1)Is that rightAlso For the update query is this right (not sure of the syntax)UPdate table1Set table1.field1 = table2.field1, table1.field2 = table2.field2Where table1.uniqueid = table2.uniqueid
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts
Posted - 2009-12-02 : 16:23:11
Insert
insert into Table1select a.* from Table2 a left join Table1 b on a.uniqueid = b.uniqueid where b.uniqueid is null
Update
Update aset a.field1 = b.field1,a.field2 = b.field2from table1 ainner join table2 b on a.uniqueid = b.uniqueid