Azure Data Studio Schema Compare

Do you need a tool for comparing database schemas? Azure Data Studio can be your answer. Let’s walk through using Azure Data Studio’s Schema Compare extension.

Installing SQL Server Schema Compare Extension

First, let’s open up Azure Data Studio. We’ll select the extensions button on the left:

And we’ll search for schema compare:

The only result is SQL Server Schema Compare which is exactly what we want. Let’s click Install, check our installed extensions again, and confirm our extension installed successfully:

Apples and Oranges

For this example, let’s compare StackTest1 and StackTest2, two smaller versions of a StackOverflow database where we only care about the Posts, Users, and Votes tables:

I’ll right click on StackTest1 and select Schema Compare.

This will open up a tab to select our source and target for comparison.

Source is filled in with StackTest1:

Let’s click the ellipses next to Target so we can set our Target as StackTest2 and click OK:

We’ll click Compare at the top left in our tab, wait for the comparison, and view our results:

Schema compare picked up that the Votes table is in the source database (StackTest1) but not the target (StackTest2).

Making Our Databases Match

What are our options to match up our databases and add Votes to StackTest2?

The quickest way to make the change would be to click the Apply button. After being prompted with an “Are you sure” message and clicking Yes, the change will be made and you will see the results of the change at the bottom of the screen under TASKS:

Another option for making our databases match is to select Generate Script. This will open up a new query window where we can review the changes:

From here, we can click Connect near the top, choose our connection, and run the script.

Make sure you have selected the “Enable SQLCMD” button at the top before running the script, or else you will see error messages. You may have noticed the red squiggly lines in the screenshot above. Once “Enable SQLCMD” is clicked, those should go away:

Now we can click Run to make our changes:

Our changes have been applied and our databases match!

Compared and Matched

Give Azure Data Studio’s schema compare extension a shot the next time you need to compare databases and apply changes.

Thanks for reading!

One thought on “Azure Data Studio Schema Compare”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s