How to format T-SQL Statements in the SSMS

Eshwar Nakkala 106 Reputation points


Can Anyone help me How to format T-SQL Statements in the SSMS


A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,563 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Vaibhav Chaudhari 38,651 Reputation points

    You can install plugins to beautify the code. See several options discussed here -

    I mostly use website to format the code and don't use any plugin as such.

    Please don't forget to Accept Answer and Up-vote if the response helped -- Vaibhav

    3 people found this answer helpful.
    0 comments No comments

  2. EchoLiu-MSFT 14,571 Reputation points

    Hi @Eshwar Nakkala ,

    You can format SQL code using SQL Server Management Studio (SSMS) native options or format SQL code using a third-party SQL formatter tool.Please refer to this link:How to format SQL code in SQL Server Management Studio

    You can also use a SSMS plugin called Poor Man’s T-SQL Formatter for formatting SQL statements and procedures.
    Installing And Using Poor Man’s T-SQL Formatter

    1. Download the Poor Man’s T-SQL Formatter plugin from
    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.

    For more details, please refer to:
    Formatting SQL Statements In SSMS

    If you have any question, please feel free to let me know.


    If the answer is helpful, please click "Accept Answer" and upvote it.

    1 person found this answer helpful.
    0 comments No comments