Edit

Share via


Schema Compare (Preview)

This article provides an overview of the Schema Compare feature for the MSSQL extension in Visual Studio Code. Schema Compare compares two database definitions, and applies the differences from the source to the target, including active database connections, .dacpac files, and SQL projects.

Schema Compare simplifies the process of comparing databases, and gives you full control when synchronizing them, even across different database versions. You can selectively filter specific differences, and categories of differences, before applying any changes.

Features

Schema Compare provides the following features:

  • Compare schemas between two .dacpac files, databases, or SQL projects.
  • View results as a set of actions to match a target against the source.
  • Selectively exclude actions listed in results.
  • Set options that control the scope of the comparison.
  • Apply changes directly to the target, or generate a script to apply changes at a later time.
  • Save the comparison.

Screenshot of the main view of Schema Compare showing differences between source and target.

Note

All features of Schema Compare are available in the preview version. You can provide feedback through GitHub.

Install the MSSQL extension

To user the Schema Compare features, install the MSSQL extension for Visual Studio Code:

  1. In Visual Studio Code, select the Extensions icon to view available extensions.

    Screenshot of installing the MSSQL extension in Visual Studio Code.

  2. Search for the SQL Server (mssql) extension and select it to view its details. Select Install to add the extension.

  3. Once installed, Reload to enable the extension in Visual Studio Code (only required when installing an extension for the first time).

Compare schemas

To compare schemas, open the Schema Compare dialog box. To do so, follow these steps:

  1. To open the Schema Compare dialog box, right-click a database in Object Explorer and select Schema Compare. The database you select is set as the Source database in the comparison.

    Screenshot of Opening Schema Compare by right-clicking a database in Object Explorer.

  2. Select one of the ellipses (...) to change the Source and Target of your Schema Compare and select OK.

    Screenshot of Changing the source and target in the Schema Compare menu.

  3. To customize your comparison, select the Options button in the toolbar.

    Screenshot of Opening the options menu in the Schema Compare.

  4. Select Compare to view the results of the comparison.

    Screenshot of Selecting the Compare button to view schema differences.

Apply changes

  1. Navigate through the object list, and ensure that you select the objects you would like to apply changes to.

    Screenshot of Viewing the list of schema differences in the Schema Compare.

  2. Apply the changes to your target.

    Screenshot of Applying selected schema changes to the target database.