SQL Source Control - 1.1
Learning SQL Source Control - 1.1
Deploying a database from source control
You can use SQL Source Control and SQL Compare to deploy a database from source control to a server.
The SQL Source Control scripts folders share the format used by SQL Compare and SQL Data Compare, so deployment is relatively simple.
The process is simplified by using SQL Server Management Studio Integration Pack which adds schema and data deployment options to the right-click menu in the Object Explorer.
Deploying with SQL Server Management Studio Integration Pack
To deploy a database schema, in the Object Explorer, right-click a database, click Schema Compare/Deploy, and click Set as Source
The SQL Server Management Studio Integration Pack Schema Compare/Deploy tab is displayed:

You can deploy the current database version or specify a version from source control.
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 SQL Server Management Studio Integration Pack
Deploying without SQL Server Management Studio Integration Pack
To deploy a database:
- Create a local copy of the scripts folder
- Migrate the local copy to the target server using SQL Compare
Optionally, you can also deploy any relevant static data using SQL Data Compare.
In this example the database WidgetDev is already in source control.
This example uses the SQL Compare and Subversion command line interfaces.
It is also possible to deploy the database using the SQL Compare graphical user interface, and a source control client such as TortoiseSVN
1) Create a local copy of the database
At a command prompt, type:
cd C:\program files\subversion\bin
svn update http://svn-eval.red-gate.com/svn/<project>/trunk/WidgetDev "C:\WidgetDevScripts"
Where:
- http://svn-eval.red-gate.com/svn/<project>/trunk/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) Migrate the local copy to the target server
At a command prompt, type:
cd C:\program files\red gate\SQL Compare 8
/sqlcompare /scr1:"C:\WidgetDevScripts"
/S2:WidgetServer /U2:<username> /P2:<password>
/db2:"WidgetTest"
/sync
Where:
- /scr1:"C:\WidgetDevScripts" specifies the local copy, WidgetDevScripts, as the source for a SQL Compare synchronization
- /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 synchronization
- /sync performs the SQL Compare synchronization, making 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 SQL Compare command line
See also |
Was this article helpful?
SQL Source Control
- Setting SQL Compare options within SQL Source Control
- "ICredentialsProvider is unset, therefore can't get" error occurring within SQL Source Control
- Linking fails due to SVN pre-commit hooks
- Logging changes to shared databases
- Object changed by Unknown
- Setting permissions for SQL Source Control
- Using SQL Source Control with Team Foundation Server 2012 or tfspreview.com
- Error: Failed to resolve no-ops after 5 tries
- Using SQL Compare or SQL Changeset scripts with SQL Source Control
all SQL products
- Compatibility of Red Gate tools in 64-bit environments
- Application has encountered an error and needs to close
- Error message after installing SQL Toolbelt - The description for Event ID ( 1 ) in Source ( nview_info ) cannot be found.
- Changing the temporary directory used by the installer
- Toolbelt Installer "hanging" while "scanning volumes"
- Login failing with "trusted SQL Server connection" error when using RunAs
all products
- Some Red Gate products identified as containing a trojan by Anti-Virus software
- Activation may fail with Unknown Error -1
- Product uses web help although a CHM file is available locally
- Argument exception resulting from missing environment variable
- Check for updates may fail when used through proxies
- 'Unidentified Publisher' error when repairing or uninstalling
- Licensing activates product as standard edition
- Moving Red Gate software products to another machine
- Red Gate tools log locations
- The application UI opening slowly when there is no internet access
SQL Source Control
- Database development models
- Release notes - version 1.0
- Release notes - version 1.1
- Release notes - version 2.0
- Release notes - version 2.1
- Release notes - version 2.2
- Requirements & prerequisites
- Technical Overview
- Release notes - version 3.0
all SQL products
all products
- Red Gate product acknowledgements
- Activating your products
- Activating your products
- Red Gate bundle history
- Check for updates
- Troubleshooting Check for Updates errors
- Current versions
- Deactivating your products
- Installing Red Gate products from the .msi file
- Requesting additional activations
- Serial numbers for bundles
- Reactivating using a different serial number
- Extending your trial
- Finding your serial numbers
- Moving a serial number from one computer to another
- No response received for manual activation
- Licensing and activation resources
- Licensing and activation resources
- Troubleshooting licensing and activation errors
- Licensing and activation FAQs
- Red Gate tools log file locations
- Download old versions of products
- Download product prerequisites & utilities
- Support & upgrades
- Upgrading your software
- Upgrading FAQs

Using SQL Source Control