I have a visual studio database project in my solution for managing changes to database and source control.
I have a script for each table under Scripts/Post-Deployment folder in the project which I run in Script.PostDeployment.sql as follows:
:r .\Data.Script1.sql
:r .\Data.Script2.sql
....
These script populate required data like lookup tables using "Insert Into tablename..." statements.
The problems I am facing are:
Is there a way in for visual studio database projects to compare data in existing database and use insert or update based on if a row already exists or not?
You should use MERGE INTO instead of INSERT INTO statements in you Data.*.sql files.