In SQL Server we often need to write a variety of SQL scripts, such as stored procedures and functions, because in the writing process, often adjust, some of the keywords we use uppercase, some we use the lowercase, some end use; For people with obsessive-compulsive disorder, it's very painful to look at code like this, and you have to manually format the code, which can be very time-consuming and laborious if the code script is much more. So the question is, how to quickly format the code in SQL Server.
I searched the internet a bit, read a foreign article said a tool apexsql, is a SQL Server Management tool plug-in, is free of charge, download down the trial, feel good. Here to share with you.
After downloading and installing, you can see the ApexSQL menu in the SQL Server Administration tool:
You can see that the default formatting shortcuts are ctrl+shift+alt+f, in the default format configuration (options under the ApexSQL menu ... ) can be modified:
Here is an example, as shown in. The left is unformatted script and the right side is the formatted script:
How to quickly format SQL Server code