Blog Post

Creating a Scripts Folder in SQL Compare

,

While I was at a conference recently, someone asked me about the Scripts Folder feature in SQL Compare and how to set that up. This post just looks at how to get SQL Compare to set up a Scripts folder on a machine.

This is a part of a series of posts on SQL Compare on my blog. You can read other posts I’ve written by clicking the link.

Getting Started

I’ve got a D: drive on my machine that looks like this.

2023-11-20 14_34_40-SanDisk500 (D_)

I’m going to create a folder, called “Compare Script Folders”, which you can see is empty. This is where I’ll store the scripts for various databases.

2023-11-20 14_35_29-Compare Script Folders

I also have a couple databases I use to test things on a local instance. You can see below my “compare1” database has a few things in it.

2023-11-20 14_49_17-googlemaps.sql - ARISTOTLE_SQL2022.way0utwest_dev (ARISTOTLE_Steve (53))_ - Micr

Now, I want to get a text copy of my schema from SQL Compare that I can use to check for changes, so let’s do that.

Creating a Scripts Folder

In order to create a scripts folder, I need to run SQL Compare. Once I do that, I see a screen like that shown below.

2023-11-20 14_51_31-SQL Compare

By default, SQL Compare looks to compare two databases. However, I can change the source. If I click the drop down next to Source, I see all of the options I have available. One of these is Scripts folder, which I’ll select.

2023-11-20 14_51_41-(local)_SQL2017.SimpleTalk_1_Dev v localhost.SimpleTalk_1_Dev.scp

Once I do this, my dialog changes. Now, I have the ability to compare a Scripts folder to a database. How do I get the Scripts folder? I click the Create link shown below.

2023-11-20 14_51_49-(local)_SQL2017.SimpleTalk_1_Dev v localhost.SimpleTalk_1_Dev.scp_

I missed this a few times, so that’s part of why I wrote this post. Once I click that, I get a new dialog. This is the one that let’s me choose the way I want to create the folder.

2023-11-20 14_52_30-Create new scripts folder

Just like the comparison, I have a number of choices for the source. I can use various items, but in my case, I’ll choose database.

2023-11-20 14_52_02-(local)_SQL2017.SimpleTalk_1_Dev v localhost.SimpleTalk_1_Dev.scp_

Once I do this, I enter the credentials to access the database. Note that I’ve clicked “Trust”, which is required for all modern versions of SQL Server. I have also selected the new folder I created.

2023-11-20 14_52_30-Create new scripts folder

Once I click Create, the engine will start to script out my database into separate files. This is the same process used when running a comparison, but in this case the results are just output to files rather than held in memory to compare with another set of objects.

2023-11-20 14_52_38-Creating scripts folder - Completed

Once the comparison completes, I see a new folder created below the folder that was in my dialog.

2023-11-20 14_52_54-Compare Script Folders

Inside this folder are all my objects, separated into different folders, which is the SQL Compare structure. This is the same structure used in SQL Source Control and Flyway.

2023-11-20 14_53_09-Tables

Now I can use this as the basis for a source or target against another source or target in SQL Compare.

If you want to do this from the menu, there’s also an item in the File menu to get the Create Scripts folder dialog.

2023-11-20 15_04_12-SQL Compare

SQL Compare is a fantastic product for simplifying work and it does so much more than this. Give it a try if you own it or download an evaluation today.

Original post (opens in new tab)
View comments in original post (opens in new tab)

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating