How to format T-SQL Statements in the SSMS

Eshwar Nakkala 106 Reputation points
2021-08-10T13:20:01.207+00:00

Hi,

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

Thanks,
Eshwar,Nakkala

Transact-SQL
Transact-SQL
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
    2021-08-10T13:59:19.583+00:00

    You can install plugins to beautify the code. See several options discussed here - https://stackoverflow.com/questions/3310188/what-free-sql-formatting-tools-exist

    I mostly use poorsql.com 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
    2021-08-11T02:02:44.323+00:00

    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 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.

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

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

    Regards
    Echo


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

    1 person found this answer helpful.
    0 comments No comments