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
- Download the Poor Man’s T-SQL Formatter plugin from http://architectshack.com/PoorMansTSqlFormatter.ashx.
- Double click the downloaded msi file and install it.
- 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.
- Go to Tools on menu and select Format T-SQL Code. The T-SQL code will be formatted.