Copy data from one table to another based on mulitple joins

This sample shows how to copy data from table A to table B based on multiple join columns.
INSERT INTO B(Value1, Value2)
SELECT DISTINCT Value1, Value2 
FROM A t1 
WHERE NOT EXISTS
(SELECT 1 FROM B t2
 WHERE t1.Value1 = t2.Value1
   AND t1.Value2 = t2.Value2)

Comments

Popular posts from this blog

Tibco Rendezvous (tibrv) C# .Net example

Parse XML to dynamic object in C#