Update to a revision from source control
Published 16 J 2015
You can update your database to a specific version from source control using SQL Compare or SQL Data Compare.
- If you want to update the schema, you need SQL Compare Pro 8.5 or later.
- If you want to update the data, you need SQL Data Compare 10 or later.
Updating to a specific version from the History dialog box
When you update to a version form the History dialog box, SQL Compare or SQL Data Compare is used to update the target database.
To update to a specific version:
In the Object Explorer, right-click the database or object and click View history:
The History dialog box opens:
- Select the version you want to update to.
- If you want to update the schema, click Update to this version with SQL Compare.
If you want to update the data, click Update to this version with SQL Data Compare. A SQL Compare or Data Compare project launches with the version you selected as the source, and the database as the target:
- To update the database, run the comparison, make sure all objects you want to update are selected, and run the deployment wizard.
For more information about comparing databases with SQL Compare, see Worked example - comparing and deploying two databases in the SQL Compare documentation.
Updating to a specific version manually
You can update to a specific version using your source control system and SQL Compare.
Update to a specific version with Git
To update to a specific version with Git:
- Using another Git tool, check out the revision you want.
- Open SQL Compare.
- Under Source:
- Select Source Control and then select Scripts folder.
- In the Scripts Folder box, select the folder, or click to browse to the folder.
- Under Target:
- in the Server box, select Database.
- Select the authentication method.
- In the Database box, type or select the database.
- Click Compare Now.
The database is updated to the version you selected.
Note that this will appear as a change to the database on the commit tab.
Update to a specific revision with TortoiseSVN
To do this, create a local copy of the revision and deploy the database using SQL Compare:
- Check out the latest version to a new folder.
- Right-click the folder, and from the TortoiseSVN menu, select Show log.
The Log Messages dialog box is displayed. - Select the revision you want to get, right-click, and click Revert to this revision.
- A confirmation dialog box is displayed. Click Yes.
The folder of scripts is updated to the revision you selected. - Using SQL Compare, set the scripts folder as the source for a comparison, and the database as the target, then compare and deploy.
The database is updated to the revision you selected.
Example: update to a specific changeset with TFS
To do this, update the TFS local copy to a specific changeset, and deploy the database using SQL Compare:
- In Visual Studio, in the Source Control Explorer tab, select the database, right-click, and click Get Specific Version.
The Get dialog box is displayed. - Under Version, in Type select Changeset.
- Type the changeset number, or click the browse button to display the Find Changesets dialog box, and select the changeset you want.
- Click Get.
The local scripts folder has been updated to the changeset you selected. - Using SQL Compare, set the local scripts folder as the source for a comparison, and the database as the target, then compare and deploy.
The database is updated to the revision you selected.