Hi I have this piece of code:
insert into table1(column1, column2) select distinct id, somevalue from table1 where id in (select id from table2) which basically is adding all the id's from table2 to table1 column1, while other columns in table1 share same values for all rows.
Now the problem is that I have to check whether an id from table2 already exists in table1 and only insert if it does not. How can I achieve that?
insert into . . . select id . . . from table1 . . ., all the ids are going to exist in table 1. Can you edit the question so it makes sense?MERGE: msdn.microsoft.com/en-us/library/bb510625.aspx