After Formatting SQL Statements in SSMS

Formatting SQL statements in SSMS

After creating a long stored procedure or function or a statement, you need to format them, so as to make it readable and maintainable. You can perform minor formatting of T-SQL statements in SQL Server Management Studio using the Query Designer. But, query designer is not robust enough and not designed for formatting stored procedures.

So, I’m using a SSMS plugin called Poor Man’s T-SQL Formatter for formatting SQL statements and procedures. Apart from SSMS, this tool can also be used as a plugin for Visual Studio and VS Code editors. It is an open source tool. The source code of this plugin is at GitHub. Let’s see how to install it and format the T-SQL Statements and procedures.

Installing and using Poor Man’s T-SQL Formatter

  1. Download the Poor Man’s T-SQL Formatter plugin from http://architectshack.com/PoorMansTSqlFormatter.ashx.
  2. Double click the downloaded msi file and install it.
  3. Now, launch the SSMS. Either select a statement to format only a specific statement in the document, or do not select anything, if you want to format the content of whole document.
  4. Go to Tools on menu and select Format T-SQL Code. The T-SQL code will be formatted.

Before formatting

Before Formatting SQL Statements in SSMS

After formatting

After Formatting SQL Statements in SSMS


Related Articles & Tools

Leave your thoughts...

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