Use the SQLCMD integration with multiple databases
Last updated: July 14, 2025
Before you begin
Add SQLCMD to your
PATH
environment variable. Alternatively, pass its location in theliquibase.sqlcmd.conf
file or at the command prompt during runtime.To use Liquibase and SQLCMD with Windows Integrated Security, follow the steps in Connect Liquibase and MSSQL Server with Windows Integrated Security and proceed with the following instructions.
Procedure
1
Create the liquibase.sqlcmd.conf file for each database you use and ensure it is in the directory from which Liquibase runs the files.
2
In each liquibase.sqlcmd.conf file, add a line like the following one.
liquibase.sqlcmd.args=-v MYDATABASE=db_dev
3
Add USE $(MYDATABASE) to each changeset that uses the runWith attribute.
Example:
USE $(MYDATABASE)
CREATE TABLE [dbo].[course] (
[CourseId] INT IDENTITY (1, 1) NOT NULL,
[Name] VARCHAR (30) NOT NULL,
[Detail] VARCHAR (200) NULL,
CONSTRAINT [PK_Course] PRIMARY KEY CLUSTERED ([CourseId] ASC) 8);