Skill 2.3.2

Create and manage reference/static data in source control

Key Concepts

SQL Database Projects model schema declaratively, but data is not part of the model, so reference data is managed with a post-deployment script that runs after every publish. The usual pattern is an idempotent MERGE from a VALUES list into the table: insert missing rows, update changed ones and, if required, delete rows that are no longer listed. Because the script runs on every deployment, it must produce the same result when run repeatedly.

A project has one post-deployment script, which can include other files with :r .\Data\Countries.sql (SQLCMD mode) to keep one file per table. Changes to reference data then go through pull requests like schema changes, and environment-specific values use SQLCMD variables rather than separate scripts. Large or frequently changing business data does not belong in source control.