In previous article ApexSQL Refactor vs RedGate® SQL Prompt – Part 4 – Additional formatting options formatting options which are found only in ApexSQL Refactor were described.
ApexSQL Refactor is a FREE SQL Server Management Studio and Visual Studio add-in which formats SQL code and SQL scripts, using nearly 200 formatting options.
In this sequel, additional formatting features, which are also found only in ApexSQL Refactor will be presented.
ApexSQL Refactor highlights the changes in the preview window for both the built-in example and the current SQL query. This feature allows to preview the impact of the chosen formatting combination.
For example, the following code is typed in the query window:
SELECT firstname , lastname , title , phonenumber , passwordhash FROM person.person INNER JOIN person.personphone ON person.businessentityid = personphone.businessentityid LEFT JOIN person.password ON person.businessentityid = password.businessentityid WHERE lastname = 'M';
To see the impact of formatting options on this query, in the Options window, choose the Preview user’s code option, in the top right corner of the window:
For every formatting option code changes will be highlighted in the preview window. Impact of the Place joined object on new line option on a current query is shown in the picture below
Choosing different option will highlight the impact of the chosen option. In the picture below, the impact of the Place ON on new line option and the Place joined object on new line option is shown:
To see the impact of the formatting options on a built-in example, click the Preview user’s code option in the top right corner of the window, to revert back to a built-in example:
Apply the formatting options and see the changes. In this case, the Always use BEGIN and END in stored procedures option is checked:
The Batch formatting feature enables formatting of many SQL scripts and folders containing .sql files at once.
To use this feature, under the ApexSQL Refactor menu choose the Format SQL scripts option:
In the Format SQL files dialog, browse to the folder where SQL scripts are saved and choose one or many .sql files for formatting:
Multiple folders or a combination of folders and SQL scripts can also be formatted simultaneously:
Formatted versions of SQL files can be saved either by creating new .sql files by choosing the Create new .sql files option, or saving changes to the original .sql files using the Overwrite old .sql files option.
For batch formatting any of the pre-defined formatting options, can be used a formatting template by choosing it from the Options drop-down list.
Using the The name format for the new .sql files option, batch formatting can be personalized, which is a useful option in a multiple users environment where every user can use personal formatting template without overwriting the files of other users:
ApexSQL Refactor vs RedGate® SQL Prompt – Part 1 – Common refactors compared “Encapsulate As”
ApexSQL Refactor vs RedGate® SQL Prompt – Part 2 – Additional refactors
ApexSQL Refactor vs RedGate® SQL Prompt – Part 3 – Common formatting options compared
ApexSQL Refactor vs RedGate® SQL Prompt – Part 4 – Additional formatting options
Disclaimer: All product and company names are trademarks™ or registered® trademarks of their respective holders. ApexSQL is not affiliated, associated, authorized, endorsed by, or in any way officially connected with them or any of its subsidiaries or its affiliates
November 21, 2013