Red Gate's SQL Refactor Boosts DBA Productivity

Using SQL Refactor

To use SQL Refactor, you launch Management Studio, and in most cases, open a new query window, where you work with your Transact-SQL code.

All SQL Refactor functionality is available from this drop-down menu in Management Studio.

Before you begin to use SQL Refactor the first time, you may want to check the SQL Refactor Option screen to see if the default values meet your needs. You have the option to control how Transact-SQL code is formatted and how identifiers are delimited, as well as the ability to create and use what are called Option Sets. Let’s take a brief look at each of these three options and what they can do for you. The screen below is the first screen you see when you choose Options.

After displaying the SQL Refactor Options screen, you are presented with three tabs. The first tab, Lay Out SQL, is where you specify how you prefer Transact-SQL code to be laid out when you tell SQL Refactor to Lay Out non-formatted or poorly formatted code.

As you can see, there are many different options you can choose in regard to how commas, indentions, wrapping, spacing, along with many more formatting options, are implemented. What is really handy about this screen is that once you choose a formatting option that formatting option is displayed immediately on the screen so you can see what you have chosen and how it looks.

For example, one of the options you have is to place commas at the end of a line, or at the beginning of a line. When you choose one of these options, the screen changes, allowing you to immediately see how the formatting works.

In the screen below, I have chosen to place commas at the end of a line.

But now, I have chosen to place commas at the beginning of a line.

As you can see from this example, it is very easy to select the code formatting options you prefer.

The next option you have is the Scripts tab, which you see below.

When SQL Refactor creates or modifies scripts, it has the ability to always delimit identifiers, or to only delimit identifiers that contain special characters or reserved words. You can choose which format you prefer.

The last tab is called Option Sets. This allows you to save a set of SQL Refactor defaults that you can recall and use over and over. Some DBAs might be satisfied with one set of default options for all their work, while other DBAs might want to have multiple default sets that represent different formatting options, depending on what they are doing.

As you can see from the above screen, you can create multiple options sets, giving each set its own unique name.

Once you have set the defaults for SQL Refactor, you are now ready to use the tool. In this next section, we take a look at all of SQL Refactor’s key features, and see how well they really work.

Continues…

Leave a comment

Your email address will not be published.