# Creating a changelog for multiple databases in sql server

**URL:** https://forum.liquibase.org/t/creating-a-changelog-for-multiple-databases-in-sql-server/4542
**Category:** General Discussion
**Created:** [August 20, 2020, 5:05pm UTC](https://forum.liquibase.org/t/creating-a-changelog-for-multiple-databases-in-sql-server/4542 "2020-08-20T17:05:03Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![duboisj](https://avatars.discourse-cdn.com/v4/letter/d/2bfe46/32.png) [@duboisj](https://forum.liquibase.org/u/duboisj)
#### Post date: [August 20, 2020, 5:05pm UTC](https://forum.liquibase.org/t/creating-a-changelog-for-multiple-databases-in-sql-server/4542/1 "2020-08-20T17:05:03Z")

</div>

I am trying to start using liquibase on an existing SQL Server database. As a starting point I would like to use liquibase to generate the existing schema with the generateChangeLog command. This is what I am doing:

./liquibase --logLevel=debug --password=“myPassword” --username=myuser --url=“jdbc:sqlserver://localhost:1433;databaseName=My\_Database\_1” --changeLogFile=mylog.mssql.sql --includeTablespace=true --includeSchema=true --includeCatalog=true --schemas=My\_Database\_1 --defaultCatalogName=My\_Database\_1 --defaultSchemaName=My\_Database\_1 generateChangeLog

If I were using plain SQL I would have a statement near the top saying

USE My\_Database\_1

The ‘myuser’ user’s default schema is not My\_Database\_1. I’m not sure what the ‘schema’ command in liquibase is doing: SQL Server has multiple databases as well as schemas, and I need to generate a changelog for more than one database within the same server instance.

Liquibase gives me:

[2020-08-20 11:46:30] SEVERE [liquibase.integration] Unexpected error running Liquibase: Cannot use default schema name My\_Database\_1 on Microsoft SQL Server because the login schema of the current user (dbo) is different and MSSQL does not support setting the default schema per session.

Is there any way to use Liquibase to generate an initial changelog with SQL Server which is running more than one database?

---

<div class="post-metadata">

### Author: ![ronak](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.liquibase.org/ronak/32/221_2.png) [@ronak](https://forum.liquibase.org/u/ronak)
#### Post date: [October 27, 2020, 7:48pm UTC](https://forum.liquibase.org/t/creating-a-changelog-for-multiple-databases-in-sql-server/4542/2 "2020-10-27T19:48:19Z")

</div>

Hi @duboisj,

> [@duboisj](#):
>
> Is there any way to use Liquibase to generate an initial changelog with SQL Server which is running more than one database?

I am not a 100% sure, I would defer to @NathanVoxland or our product team (@Pete / @mariochampion) but a workaround could be to generate changelog per schema individually (so multiple liquibase generateChangelog commands).

Backing up a sec:  
What do you plan to do with those changelogs? Do you have other environments you need to seed and the source db is your baseline? Otherwise if all environments are already synchronized (as in the same schema exists across enviornments), you can just start creating changesets and use liquibase moving forward, no need to generate what is already there.

-Ronak
