r/dbForge • u/dbforge_dev • 5h ago
Showcase SQL Server schema compare checklist: before you run that sync script
Schema drift usually shows up as "it worked on staging". Somebody added an index on prod during an incident, a proc was hotfixed directly, a column type changed in one environment only. Here's a checklist for using schema compare so it catches that before a deployment does.
First, schema compare vs data compare
Schema compare looks at structure: tables, columns, indexes, constraints, procedures, views, permissions. Data compare looks at rows inside tables. A changed column type is a schema difference. Missing rows in a lookup table is a data difference. Deployments often need both, but run them as separate steps and review them separately.
Before you compare
- Decide what the source of truth is. It can be a live database, a scripts folder in Git, a snapshot file, or a native backup.
- Take a snapshot of the target before you change anything. A snapshot holds only the schema, and later you can use it as a source to roll the structure back.
- Set the ignore options so noise doesn't hide real changes: whitespace, comments, case, and similar.
- Filter out objects you don't manage, for example permissions handled by another team.
When you review the results
- Read the DDL diff per object, not just the count of differences.
- Look for operations that can lose data: dropped columns, narrowed types, table rebuilds.
- Read the dependency warnings even though the tool orders the script for you.
When you generate the script
- Save the sync script to a file instead of running it straight against prod. Review it like any other change, ideally in a PR.
- Add a timestamp to output file names so reports and scripts don't overwrite each other.
When you move it into CI
- Save the comparison as a project file (.scomp) or an arguments file, then call it from the pipeline.
- Use the exit code. 100 means identical, 101 means differences found, 40 means the connection failed. Treat 101 as a failed check or an alert.
- Publish the HTML report as a build artifact so people can see what drifted without opening the tool.
- Keep passwords in your CI secrets. Generated argument files don't include them anyway.
- Don't run auto sync to prod from CI unless a person has reviewed the script.
A minimal drift check looks like this:
schemacompare.com /schemacompare /compfile:"prod_vs_main.scomp" /report:"drift.html" /reportformat:html /log:"drift.log"
if %ERRORLEVEL%==101 (echo Schema drift detected)
If you need to check one reference database against many targets, the same command works in a loop over a text file with connection details.
All of this works in dbForge Schema Compare for SQL Server, which runs standalone or as an SSMS add-in and is also part of the all-in-one IDE dbForge Studio for SQL Server. The CLI options and exit codes are documented here: https://docs.devart.com/schema-compare-for-sql-server/using-the-command-line/comparing-and-sync-schemas-through-command-line.html