SQL Source Control 7

Deploy with the SQL Compare command line

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.

Additional licensing

Automated deployments of SQL Source Control projects require licensing via either the SQL Toolbelt or Redgate Deploy. See our EULAs for more information

To deploy from source control using the SQL Compare command line

  1. Create a local copy of the scripts folder
  2. 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"

Where:

  • 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

Where:

  • 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.


Didn't find what you were looking for?