Do conditional INSERT with SQL?

You can do that with a single statement and a subquery in nearly all relational databases. INSERT INTO targetTable(field1) SELECT field1 FROM myTable WHERE NOT(field1 IN (SELECT field1 FROM targetTable)) Certain relational databases have improved syntax for the above, since what you describe is a fairly common task. SQL Server has a MERGE syntax with … Read more