question

EshwarNakkala-4064 avatar image
0 Votes"
EshwarNakkala-4064 asked EchoLiu-msft commented

How to format T-SQL Statements in the SSMS

Hi,

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

Thanks,
Eshwar,Nakkala

sql-server-transact-sql
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Could you please validate all the answers so far and provide any update?
If all of them are not working or helpful, please provide more sample data or details about your issue.
Please remember to accept the answers if they helped. Your action would be helpful to other users who encounter the same issue and read this thread.

Thank you for understanding!

0 Votes 0 ·
VaibhavChaudhari avatar image
0 Votes"
VaibhavChaudhari answered

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

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

EchoLiu-msft avatar image
0 Votes"
EchoLiu-msft answered EchoLiu-msft edited

Hi @EshwarNakkala-4064,

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.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.