Adding "IF NOT EXISTS" clauses on insert statements?
tim-s
Posts: 2
I tried searching on this but came up blank ... basically, I'm using SQL Comparer SDK to compare the data in a master database to an older version so we can use the generated scripts to update multiple client-side databases to a newer version.
In the generated scripts, we really need each "INSERT" statement to be wrapped in an "IF NOT EXISTS" clause to avoid overwriting any conflicting client data with our default data. Is there some option I can set somewhere to force this?
Thanks!
In the generated scripts, we really need each "INSERT" statement to be wrapped in an "IF NOT EXISTS" clause to avoid overwriting any conflicting client data with our default data. Is there some option I can set somewhere to force this?
Thanks!
Comments
If so, you might want to investigate controlling which differences are selected - I've not tried this on some useful data as yet, but something along the lines of:
foreach (TableDifference d in session.TableDifferences)
{
d.SqlSynchronization = SqlSynchronization.AddSql;
}
Should make it only generate SQL for records to be inserted, leaving those that already exist (SqlSynchronization.UpdateSql) alone.
Redgate Software