KS DB Merge Tools logo KS DB Merge Tools
database diff & merge
MssqlMerge logo for SQL Server
aka MssqlMerge
KS DB Merge Tools for Oracle logo
KS DB Merge Tools for MySQL logo
KS DB Merge Tools for PostgreSQL logo
KS DB Merge Tools for SQLite logo
AccdbMerge logo
KS DB Merge Tools for Cross-DBMS logo
KS DB Merge Tools All-In-One license

Automation and Scripting

MssqlMerge can do a lot of database diff and merge tasks without user interaction. It has its own scripting language, designed to automate the most common tasks.

For example, you need to create a continuous integration (CI) nightly build that checks for schema changes between your Dev server database and Staging database. Such a report could be easily generated using MssqlMerge GUI: we just need to get schema changes summary (see Schema changes summary use case). Then using the toolbar we need to apply a 'New and Changed' filter and then do Export. But all these actions should be done by someone, that's not applicable for our task that should be done without user interaction.

Let's automate this task. Open Script Editor application:

for SQL Server, click query result diff

As recommended in the sample script comments, update 1 your connection strings, 2 script log and 3 json report file paths. Script sample already contains required command to generate schema summary report, if you need some other actions - please check the documentation. Сlick 4 to check the script and make sure the Result panel has no errors. If so, click 5 to run the script and check its execution result. Select and copy text of your script, paste it into some text editor and save as file with *.ksdms extension. Now, assuming that you have MssqlMerge installed on CI server, you can create a task in your CI pipeline that would run the following command:

"c:\Program Files (x86)\MssqlMerge\MssqlMergeCmd.exe" "c:\temp\schemaDiff.ksdms"

where MssqlMergeCmd.exe argument should be a real path to your *.ksdms file.