SQLTreeo Compare command line
Run schema, server and data comparisons from CI pipelines with the sqlcompare command.
The sqlcompare command line runs the same comparison engine as the desktop application, without a UI. Download the CLI zip from the downloads page and extract it on the build server or agent.
Commands
Schema comparison with a deployment script and an HTML report:
sqlcompare schema --source "Server=dev;Database=Shop;Integrated Security=true" --target "Server=test;Database=Shop;Integrated Security=true" --script deploy.sql --format html --output report.html
Server comparison for DBAs, ignoring hardware and file path differences:
sqlcompare server --source "Server=prod1;Integrated Security=true" --target "Server=prod2;Integrated Security=true" --ignore-hardware --ignore-paths
Data comparison of the sales schema, ignoring columns that start with Modified:
sqlcompare data --source "Server=dev;Database=Shop;Integrated Security=true" --target "Server=test;Database=Shop;Integrated Security=true" --table "sales.*" --ignore-column "Modified*"
Deploy from a pipeline
The script is generated, analysed for DROP and data-loss statements, and executed against the target inside a transaction. The exit code is 0 when the deployment succeeds.
sqlcompare schema --source "Server=dev;Database=Shop;Integrated Security=true" --target "Server=test;Database=Shop;Integrated Security=true" --deploy --script deploy.sql
Write the DBA configuration script for a server comparison without DROP statements:
sqlcompare server --source "Server=prod1;Integrated Security=true" --target "Server=prod2;Integrated Security=true" --script configure-prod2.sql --no-drops
Exit codes
| Code | Meaning |
|---|---|
| 0 | No differences, or the deployment succeeded |
| 1 | Differences found |
| 2 | Error |
Environment variables
| Variable | Effect |
|---|---|
SQLCOMPARE_SOURCE / SQLCOMPARE_TARGET |
Connection strings, instead of --source and --target |
SQLCOMPARE_LICENSE_KEY |
Activates a license key on unattended machines |
SQLCOMPARE_DEBUG=1 |
Prints stack traces for errors |
Run sqlcompare <command> --help for all options.
Use of the command line tool on a build, automation or shared server requires a license key for each such server. See the license agreement.