SQL Compare - 10.0
Worked example: Using a scripts folder as a data source - SQL Compare
This worked example demonstrates the use of a scripts folder when comparing and deploying databases. A scripts folder contains SQL script files representing a database's structure and, optionally, data.
For more information, see: Working with scripts folders.
In the example, the Super Sprocket Company has a SQL Server database that contains a number of tables, views, stored procedures, and other database objects. The Super Sprocket Company's development team has been given the task of making a number of changes to the structure of the database and updating the production server.
A copy of the production database has already been restored to an empty database, ready for development. To ensure no untested changes are made to the production database, they will also save its schema as a scripts folder.
You can follow the example on your own system, if you are using SQL Compare Professional edition. You will need access to a SQL Server to do this.
If you have not already followed the Comparing and deploying two databases worked example, you are recommended to do so before starting this worked example.
This example has four stages:
- Set up the databases
Create the example databases on your SQL Server.
- Set up the comparison
Specify the data sources you want to compare.
- Select objects to deploy
Review the results and select the objects you want to deploy.
- Create a deployment script
Create a script to update the production database.
Note that you can only compare scripts folders if you are using SQL Compare Professional Edition.
1. Set up the databases
The worked example uses the following databases:
- SprocketProduction is the production database
- SprocketDevelopment is the modified version of the database containing the updates
To create these databases on your SQL Server:
- If they already exist, delete the databases SprocketProduction, and SprocketDevelopment from your SQL Server.
- Click here to view the SQL creation script for the databases.
- Copy the script, paste it in your SQL editor, and run it.
The databases and their schema are created.
2. Set up the comparison
Development on the copy of the production database proceeds, and at some point a milestone is reached; the next version is ready to be tested. The development team compares the modified database with the production database schema. To ensure no untested changes are made to the production database, they save its schema as a scripts folder.
Creating a scripts folder before deployment preserves the current state of the production database. It can be checked into source control, providing history and allowing you to revert any changes.
To do this, set up a comparison project:
- Click
(New Project).If an unsaved project is currently open, you will be prompted to save when you click

The Project Configuration dialog box is displayed:

- Under Source, select Database, and in the Database box type or select SprocketDevelopment.
SprocketDevelopment is the new version of the database, following a development cycle.
You must now create a scripts folder representing the schema of the production database.
- Under Target, select Source Control, then select Scripts folder:

- Click Create schema scripts:

The Create New Scripts Folder dialog box is displayed:

- Ensure that the Data source type is set to Database.
- Type or select SprocketProduction in Database.
If the database is not displayed in the Database list, right-click in the Database box and click Refresh, or scroll to the top of the list and click Refresh.
- Click in the New folder name box. SQL Compare automatically supplies a name for the scripts folder.
The default value is the name of the data source.
In this example, use the default name SprocketProduction.
- In Create in, type the path for the folder you want to create, or click
Browse to browse to its location.If you are using a source control system, this may be the folder designated as your working folder.
- Click Create Scripts Folder.
The schema is saved in the specified folder as a set of object creation script files.
The folder you created is now shown as the target of the comparison on the Project Configuration dialog box.
- Click Compare Now.
A message dialog box is displayed. If you selected the Close dialog box on completion check box last time you ran a comparison, SQL Compare closes this message dialog box automatically.
3. Select objects to deploy
The comparison results are displayed in the main window:

To update the production database, you must create a deployment script. Verify that all the objects you want to modify are present in the comparison results, and select them for deployment.
To search for objects, type the search text in the Find box. SQL Compare searches object names and owner names.
In this example, search for all objects that contain "price" by typing price in the Find box.

The objects are now grouped by whether they match or do not match the find text. To clear the Find box, click the
button; all the objects are displayed.
You can view a side-by-side, color-coded listing of the differences in the object creation scripts, by clicking an object. For example, if you click the Sprockets table, you can see the differences for this table:

The two versions of the line are shown one on top of the other in the Line Differences bar. This is especially useful when the lines are too long to view all the text; you can see more of each line in the Line Difference bar. If the Line Differences bar is not displayed, click
and select Line Differences
For full details of how to use the comparison results window, see:
In this example we will deploy all objects.
In the central column of the upper (Results) pane, select the top level check box to include all objects in the deployment:

4. Create a deployment script
When you have selected the objects to deploy, click
Deployment Wizard.
1. Choose deployment method
When a scripts folder is the target, you can:
- Create a deployment script to update the database from which the scripts folder was created
- Modify files in the scripts folder directly
In this example, we will create a deployment script. The script can then be run on the production database to update it with the development changes.

- Ensure that Create a deployment script is selected.
- Click Next.
2. Review script

When you have reviewed the script, you can open it in your SQL editor, or save a copy of the script.
- Click Open Script in Editor.
The script is opened in your default SQL editor, and can be run on the SprocketProduction database to update it with the development changes.
- Run the script.
To verify that the deployment was successful, set up a new project comparing SprocketDevelopment and SprocketProduction.
If you have not saved the project, you will be prompted to do so when you click

It is not necessary to save the current project.
As the databases are now identical, All objects identical is shown in the direction bar:

See also |
Was this article helpful?
SQL Compare
- Logging and log files
- Stored Procedures and Functions created with wrong name
- Synchronization scripts may be in incorrect version of SQL syntax
- Extended properties not permitted error (version 5.2)
- CLR Procedures' permissions are not recreated (version 5)
- Support for 'returns NULL on NULL Input' in CLR functions (version 5)
- Project files (scp files) suddenly appear on desktop (version 5)
- Stored procedures using full-text queries fail to synchronize
- When does the synchronization process rebuild tables?
- Unable to begin a distributed transaction error synchronizing databases
- User or role already exists in the current database error
- Clarification on the "Ignore Triggers" option in the SQL Compare command-line version
- Common table expressions returned by User Defined Functions may fail
- Can't compare encrypted text in SQL Server 2005, 2008
- Exception when connecting to SQL Server (Version 6)
- SQL comparison and synchronization automation capabilities
- Error logging in SQL Compare 6.2
- Using Team Foundation Server source control system
- Creating a SQL 2000 compatible database from a SQL 2005 database using SQL Compare
- Support for numbered stored procedures
- SQL Compare 7 Object-level restore
- Index was outside the bounds of the array error when registering databases X64
- HTML reports are generated for identical comparisons
- Comparison may seem slower than necessary
- DEFAULT_SCHEMA clause cannot be used with a Windows group
- SQL Compare may drop and create CLR assemblies
- SDK activation prompt may appear when starting a new SQL Compare project
- Column does not allow nulls. INSERT fails
- This SQL Server has been optimized for x concurrent queries.
- SQL Compare comparison differences
- Using SQL Server Management Studio Express as a query editor
- How to force SQL Compare and SQL Data Compare to use an Encrypted Connection
- Invalid SQL when synchronizing an index to a scripts folder when data compression is specified
- Tips
- Changes to distribution of command line
- Common error messages
- Copying the structure of a database
- Permissions required to use SQL Compare
- Rollback on script failure or cancellation
- Errors in scripts folders
- Logging and log files
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 Compare
- Activating your products
- Activating your products
- Getting help offline
- Release notes - version 9.5 EAP
- Introducing SQL Compare 8: FAQs for SQL Compare 7 users
- Release notes - version 10.xx
- SQL Compare release notes - version 9.xx
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 Compare