Use native executors with Microsoft SQL Server

Last updated: July 14, 2025

Before you begin

  • Add SQLCMD to your PATH environment variable. Alternatively, pass its location in the liquibase.sqlcmd.conf file or at the command prompt during runtime.

  • To use Liquibase and SQLCMD with Windows Integrated Security, follow the steps in Using Liquibase and MSSQL Server with Windows Integrated Security and proceed with the following instructions.

Procedure

1

Add the runWith attribute to the needed changesets in the changelog.

  • SQL: runWith:sqlcmd

  • XML: runWith="sqlcmd"

  • YAML: runWith: sqlcmd

  • JSON: "runWith": "sqlcmd"

2

Specify the SQLCMD integration arguments in one of the following ways:

  • Pass the values at runtime on the command line.

  • Add the values to liquibase.sqlcmd.conf or the Liquibase properties file.

  • Set the values as environment variables.

  • Run the values as Java system properties (JAVA_OPTS) along with any command at the command prompt.

Windows
set JAVA_OPTS=-Dliquibase.sqlcmd.<option>=<value> && liquibase <command> --changelog-file=my_script.sql
Linux/macOS
export JAVA_OPTS=-Dliquibase.sqlcmd.<option>=<value> && liquibase <command> --changelog-file=my_script.sql
3

Run a Liquibase command.

Example: liquibase status --changelog-file=my_script.sql

Note: If the command fails, you will receive an error message. However, if you add a property that is not used in Liquibase to the liquibase.sqlcmd.conf file, no error occurs. Liquibase only ignores it.

Liquibase 4.29+: Using SQLCMD allows you to generate one log file per executed changeset via runWith, any Update Commands, and any Rollback Commands . This allows for close inspection of each changeset once it has been run to audit the latest operations' actions. These logs are stored in your liquibase.sqlcmd.config file and are labeled with the Changeset author and ID.

Example: sqlcmd-<developername>-<changeset-id-1>.log