Copyright: Original Works are allowed to be reproduced. During reprinting, be sure to mark them as hyperlinks. Article Original source, author information, and this statement. Otherwise, legal liability will be held. Http://www.cnblogs.com/jintan/archive/2008/03/27/1125853.html
If you write too many SQL statements, it will inevitably lead to headaches for messy SQL statements.CodeIt looks comfortable, eye-catching, and clear.
T-SQL statement itself does not have the formatting standard, so, basically everyone has their own style, and currently see formatting SQL tool does not seem to be much, or the function is very weak, in fact, the most ideal thing is to integrate SQL code format functions into the development environment, such as integration into SQL Server Management or VS, which is more convenient.
Now let's take a look at the SQL Server Management built-in small stuff to format the SELECT statement, known as "design query in the editor" (the last button in). It is estimated that many friends did not notice
The original messy SQL statement is as follows:
Select C. fname, C. furl, B. fdisplayname, B. fmoduleid, B. ffuncname,. fauflag, B. frelpageurl from funcinroles as a inner joinfuncinfos as B on. ffuncid = B. ffuncid inner join modules as C on C. fmoduleid = B. fmoduleidwhere (. froleid = @ roleid) and (B. fmoduleid = @ fmoduleid) and (. fschoolid = @ schoolid)
Select the code to be formatted in the code editor. Click
The code is formatted immediately, as shown in figure
Formatted code:
Select C. fname, C. furl, B. fdisplayname, B. fmoduleid, B. ffuncname,. fauflag, B. frelpageurlfrom funcinroles as a inner joinfuncinfos as B on. ffuncid = B. ffuncid inner joinmodules as C on C. fmoduleid = B. fmoduleidwhere (. froleid = @ roleid) and (B. fmoduleid = @ fmoduleid) and (. fschoolid = @ schoolid)
Haha, formatting is not ideal, but it is much better than the original one. In addition, this stuff can only format the SELECT statement. After all, it is just a query designer. Don't report too high expectations.
I hope to help you.
I will release the SQL Server 2005 and vs 2008 plug-ins developed by me in a few days. The functions include:
- Complete SQL code formatting
- Quickly locate and search database objects
- SQL code area collapse # region... # endregion
- .....