I need to insert rows from select, if key is duplicate then delete entry and insert them
Table1
ColumnA ColumnB ColumnC ColumnD
A 1 A1 7/21/2017
B 2 B1 7/22/2017
C 3 C1 7/23/2017
Unique Combination ColumnA and ColumnC
Table2
ColumnE ColumnF ColumnG
A 1 A1
A 2 A2
B 3 B1
B 2 B2
C 3 C1
C 1 C2
I should insert the rows from table 2 to table 1
Insert into table1 (columnA, columnB, ColumnC) select columnE, ColumnF, ColumnG from table2
The above query gets conflicts saying duplicate keys are inserted but want a way to delete rows which creates conflicts and insert that row. final output should be
Table 1
ColumnA ColumnB ColumnC ColumnD
A 1 A1 08/08/2017 - deleted and added as conflict arised
A 2 A2 08/08/2017
B 3 B1 08/08/2017 -deleted and added as conflict arised
B 2 B2 08/08/2017
C 3 C1 08/08/2017
C 1 C2 08/08/2017