Automatic T-SQL Formatting with Microsoft SQL Server Management Studio 2014

Within MySql Workbench, there’s a feature called “Clean Up SQL” which automatically tidies up your SQL and the indentation automatically.

This is a very useful feature, as your messy SQL then becomes nice and neat. Unfortunately with Microsoft SQL Server Management Studio (SSMS), this feature is not standard.

Poor Mans T-SQL Formatter - Format T-SQL CodeLuckily I came across the following open source T-SQL formatter library, complete with an add-in for SSMS which adds this functionality – Poor Mans T-SQL Formatter. This plugin automatically formats your SQL, adding tabs and linebreaks etc in order to make it easy to read.

After installing the product, the following folder needs renaming in order to work with the 2014 version of SSMS:

%SystemDrive%\ProgramData\Microsoft\SQL Server Management Studio\11.0


%SystemDrive%\ProgramData\Microsoft\SQL Server Management Studio\12.0

This is due to the installer. The installer puts the files in the incorrect place for the 2014 version of SQL Management Studio. Once you have renamed the folder and restarted SSMS, it will automatically add the options to the Tools menu.
Poor Mans T-SQL Formatter File Changes

Not only does this plugin work for SQL Management Studio, there are also versions for:

If you don’t wish to install the software, there’s an online version available.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.