To deploy a database from source control to a server, use SQL Compare Pro, or the SQL Server Management Studio Integration Pack add-in.
Deploying with SQL Compare
To deploy with SQL Compare:
- Open SQL Compare.
- Select a version from source control.
For full instructions, "Selecting a version from source control" on the Setting data sources page (SQL Compare documentation).
- Run the comparison.
- Open the Deployment Wizard and deploy the version.
For full instructions, see Deploying data sources (SQL Compare documentation).
Deploying with SQL Server Management Studio Integration Pack
To deploy a database schema:
- In the Object Explorer, right-click a database, select Schema Compare/Deploy > Set as Source.
The SQL Server Management Studio Integration Pack Schema Compare/Deploy tab opens:
- By default, the database is set as the source.
To deploy a version from source control, select Source Control and specify the version.
- On the right-hand side, choose what you want to deploy to.
You can deploy to a target database, create a new database, or create a change script to update a target source control version.
For more information, see Getting started with the add-in (SQL Compare documentation).
Deploying with the SQL Compare command line
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:
- 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:
- 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.