Compare and synchronize scripts folders

A scripts folder contains a collection of scripts that define a database schema and, optionally, static data. Each database object is represented by an individual script file. These files can be organized into user-defined subfolders, typically grouped by object type.

Scripts folders can be used for:

  • Version control: Store script files in a version control system to track and manage changes to database objects.
  • Cross-server comparison: Compare database objects between servers that are not directly connected.
  • Database reverse engineering: Generate a script-based representation of an existing database for analysis or migration.

Note

The Scripts folder feature is available only in the Enterprise edition.

A scripts folder stores the following components:

  • Database object scripts: Organized into subfolders by object type: Programmability, Security, Storage, Tables, and Views. Each subfolder contains individual .sql files with CREATE statements for the objects in that category.
  • Static data scripts: A dedicated folder containing .sql files with INSERT statements for static data, organized by table.
  • config.xml file: Stores metadata about the scripts folder, including the SQL Server version, database collation, and associated database name (entity).
  • Database-level script: A single .sql file containing ALTER DATABASE statements applicable to the database as a whole.

Scripts folder synchronization limitations

Before using scripts folders in comparison and synchronization, consider the following:

  • When a scripts folder is used as a source, certificates, symmetric keys, and asymmetric keys are not supported.
  • When a scripts folder is used as a target, any comments inside a table definition are lost if the table is modified, and the object creation script is regenerated.
  • Scripts folder comparison can be used to copy or transfer database schema and static data. To move data, use the Scripts Folder feature in the Data Compare tool.

Compare and synchronize scripts folders with other data sources

dbForge Studio can compare scripts folders even if their structures differ or when all objects are stored in a single .sql file.

Note

Scripts folders can be created using dbForge tools or third-party utilities. During synchronization, however, dbForge Studio organizes objects according to its standard folder structure, regardless of the original layout.

When you compare and synchronize scripts folders as either the source or the target, dbForge Studio generates a synchronization script. You can save this script to a file or open it in the internal editor for review.

  • When a scripts folder is the source: You can execute the synchronization script directly against the target database or generate a migration script.
  • When a scripts folder is the target: You can update the folder after synchronization or generate a migration script.

Compare and synchronize scripts folders as the source

1. Open the New Schema Comparison wizard in one of these ways:

  • In the top menu, select Comparison > New Schema Comparison.
  • On the Start Page, select Database Sync > New Schema Comparison.

2. Under Source:

2.1. In Type, select Scripts Folder.

2.2. In Database scripts folder, select one of the following options:

  • Select the previously added scripts folder.

  • Click New to create a scripts folder and add it to schema comparison.

  • Click the ellipsis (…) and select the scripts folder.

3. Under Target, select the data source to compare with the scripts folder, then configure the data source settings.

Add a scripts folder to schema comparison as the source

4. On the Options page, select the Ignore spaces in object name and Ignore white spaces options.

These options help avoid issues with how SQL Server interprets leading and trailing spaces in the object definitions of views, stored procedures, functions, triggers, user-defined types, defaults, and rules.

5. Click Compare.

The comparison results appear in the Schema Comparison document.

By default, all objects are selected for synchronization. To exclude any objects from synchronization, clear the checkboxes next to the corresponding objects.

View comparison results

6. At the top of the document, click Synchronize objects to the target database to open the Schema Synchronization Wizard.

7. Select an output option to generate a synchronization script, and optionally configure the synchronization settings.

8. Click Synchronize.

Compare and synchronize scripts folders as the target

1. Open the New Schema Comparison wizard in one of these ways:

  • In the top menu, select Comparison > New Schema Comparison.
  • On the Start Page, select Database Sync > New Schema Comparison.

2. Under Source, select the data source to compare with the scripts folder, then configure the data source settings.

3. Under Target:

3.1. In Type, select Scripts Folder.

3.2. In Database scripts folder, select one of the following options:

  • Select the previously added scripts folder.

  • Click New to create a scripts folder and add it to schema comparison.

  • Click the ellipsis (…) and select the scripts folder.

Add a scripts folder to schema comparison as the target

4. On the Options page, select the Ignore spaces in object name and Ignore white spaces options.

5. Click Compare.

The comparison results appear in the Schema Comparison document.

By default, all objects are selected for synchronization. To exclude any objects from synchronization, clear the checkboxes next to the corresponding objects.

View comparison results in the Schema Comparison document

6. At the top of the document, click Synchronize objects to the target database to open the Schema Synchronization Wizard.

7. Select an output option to generate a synchronization script, and optionally configure the synchronization settings.

Tip

When the scripts folder is selected as the target, you can change the folder structure in the Scripts Folder Structure dialog. For this, select Update the scripts folder, then click Scripts Folder Structure.

8. Click Synchronize.

Create a scripts folder

You can create a scripts folder in one of these ways:

  • Use the Create Scripts Folder or Snapshot dialog.
  • Compare and synchronize a scripts folder as the target.

Create a scripts folder using the Create Scripts Folder or Snapshot dialog

1. In the top menu, select Database > Tasks > Create Scripts Folder or Snapshot.

2. In the dialog, select a database and server connection as the source.

3. Enter the full path to the destination scripts folder that will be created.

4. Optional: Select Include data to insert static data.

5. Optional: Click Scripts Folder Structure to customize the scripts folder structure and file name templates.

6. Click Create.

Create a scripts folder using the Create Scripts Folder or Snapshot dialog