Deploy with the SQL Compare command line
Published 15 March 2021
When to use this deployment option
This option is suitable for automated deployment scenarios where you do not wish to have full CI/CD support.
Use of the SQL Compare command line may also be useful in full CI/CD pipelines where you wish to generate additional scripts or comparisons as part of a custom workflow.
To deploy from source control using the SQL Compare command line
- Create a local copy of the scripts folder
- Deploy the local copy to the target server using SQL Compare
1. Create a local copy of the repository
You need to create a copy of the scripts folder that represents the database in your repository.
For example, for Subversion, at command prompt, you'd type:
cd C:\program files\subversion\bin svn update http://<your repository path>/WidgetDev "C:\WidgetDevScripts"
- C:\program files\subversion\bin is the location of the Subversion command line
http://<your repository path>/WidgetDev is the URL for the database in your Subversion repository
- C:\WidgetDevScripts is the file path for the directory where the local copy will be created
A local copy of the scripts folder is created. This is a Subversion working copy, and is associated with the Subversion repository.
2. Deploy the local copy to the target server
At a command prompt, type:
cd C:\program files\red gate\SQL Compare 12 /sqlcompare /scr1:"C:\WidgetDevScripts" /S2:WidgetServer /U2:<username> /P2:<password> /db2:"WidgetTest" /sync
- C:\program files\red gate\SQL Compare 12 is the location of the SQL Compare command line
- /scr1:"C:\WidgetDevScripts" specifies the local copy, WidgetDevScripts, as the source for a SQL Compare deployment
- /S2:WidgetServer /U2:<username> /P2:<password> specify the server, user name, and password you are using
- /db2:WidgetTest specifies WidgetTest as the target of a SQL Compare deployment
- /sync performs the SQL Compare deployment, making the schema of WidgetTest the same as the schema in WidgetDevScripts
The database is updated. Its schema is now the same as the version you checked out of source control.
For more information, see Simple examples using the command line.