Answered by:
How to format my SQL Code in Management Studio 2008

Question
-
I have installed Sql Server 2008 management studio, and I want to use sql editor for formatting my sql code. for example. I have wrote this code as follow: always more
create table mytestTable ( myId int primary key, myCode varchar(20) not null, myValue varchar(100))
and it is hard to read. and I want to format my code as follow
create table mytestTable
(
myId int primay key,
myCode varchar(20) not null,
myValue varchar(100)
)
I follow this step:
1:right click on toolbar and select customize
2:chose edit and find document format button in right box.
3:type my code in sql editor and finish it. but the "format the whole document " button is disalbe. so I can't to format my code.
thanks and best regard.
yours chalin
2009-8-6
Although my hair is Chaotic.Thursday, August 6, 2009 1:14 PM
Answers
-
SSMS doesn't have such functionality. This button is probably just a leftover from the VS interitage. See if perhaps http://www.ssmstoolspack.com/ is useful for you.
Tibor Karaszi, SQL Server MVP http://www.karaszi.com/sqlserver/default.asp http://sqlblog.com/blogs/tibor_karaszi- Marked as answer by Xiao-Min Tan – MSFT Friday, August 14, 2009 9:44 AM
Thursday, August 6, 2009 2:49 PM -
The button is from XML Editor and it has a different purpose. Like Tibor said, there is no built-in support for such a feature in SSMS 2008.
Check the following FREE formatter from ApexSQL. It has SSMS add-in too:
http://www.apexsql.com/sql_tools_refactor.asp
Here is a demo video:
http://www.apexsql.com/Video/Flash/ApexSQL%20Refactor/ApexSQL%20Refactor.htm
Hope it helps.
Varsham Papikian, New England SQL Server User Group Executive Board, USA: www.nesql.org; http://www.linkedin.com/in/varshampapikian- Proposed as answer by Papy Normand Sunday, August 9, 2009 3:49 PM
- Marked as answer by Xiao-Min Tan – MSFT Friday, August 14, 2009 9:45 AM
Thursday, August 6, 2009 2:57 PM -
Hi,
I found a webpage to format SQL statements, you can try it:
http://www.dpriver.com/pp/sqlformat.htm
Note: This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.
If there are any more questions, please let me know.
Thanks.
***Xiao Min Tan***Microsoft Online Community***- Marked as answer by Xiao-Min Tan – MSFT Friday, August 14, 2009 9:45 AM
Thursday, August 13, 2009 11:06 AM
All replies
-
SSMS doesn't have such functionality. This button is probably just a leftover from the VS interitage. See if perhaps http://www.ssmstoolspack.com/ is useful for you.
Tibor Karaszi, SQL Server MVP http://www.karaszi.com/sqlserver/default.asp http://sqlblog.com/blogs/tibor_karaszi- Marked as answer by Xiao-Min Tan – MSFT Friday, August 14, 2009 9:44 AM
Thursday, August 6, 2009 2:49 PM -
The button is from XML Editor and it has a different purpose. Like Tibor said, there is no built-in support for such a feature in SSMS 2008.
Check the following FREE formatter from ApexSQL. It has SSMS add-in too:
http://www.apexsql.com/sql_tools_refactor.asp
Here is a demo video:
http://www.apexsql.com/Video/Flash/ApexSQL%20Refactor/ApexSQL%20Refactor.htm
Hope it helps.
Varsham Papikian, New England SQL Server User Group Executive Board, USA: www.nesql.org; http://www.linkedin.com/in/varshampapikian- Proposed as answer by Papy Normand Sunday, August 9, 2009 3:49 PM
- Marked as answer by Xiao-Min Tan – MSFT Friday, August 14, 2009 9:45 AM
Thursday, August 6, 2009 2:57 PM -
You may want to type what you have this way
create table mytestTable
(
myId int primay key,
myCode varchar(20) not null,
myValue varchar(100)
)
then highlight your parameters
and click the increase indent buttonFriday, August 7, 2009 6:52 AM -
I am sorry, may be I don't depict clearly.
when I modify a procedure which create by other colleague. and he don't format the code, it is hard to read.
and I want to use some tool to format the code. just like as PL/SQL -->beautify
Although my hair is Chaotic.Sunday, August 9, 2009 9:45 AM -
As stated earlier in this thread, SQL Server do not come with a beautifier, so you have to use some 3:rd party util for that (see for instance the links already provided).
Tibor Karaszi, SQL Server MVP http://www.karaszi.com/sqlserver/default.asp http://sqlblog.com/blogs/tibor_karasziSunday, August 9, 2009 11:50 AM -
Hi,
I found a webpage to format SQL statements, you can try it:
http://www.dpriver.com/pp/sqlformat.htm
Note: This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.
If there are any more questions, please let me know.
Thanks.
***Xiao Min Tan***Microsoft Online Community***- Marked as answer by Xiao-Min Tan – MSFT Friday, August 14, 2009 9:45 AM
Thursday, August 13, 2009 11:06 AM -
I am getting back to microsoft toolset after a break of almost 10 years. Boy, I thought things have improved a lot but MS still sucks. Where is the basic code formatter for SQL statements? Pick any DB or opensource tool and this is a basic feature. Back to my good old squirrel client. MS Continue to suck. Thousands of dollars plunked down the drain to buy a really crappy tool.Friday, December 3, 2010 5:18 PM
-
You can format your SQL Code online using the below link.
sql server code formatter online
http://sqlserverlearner.com/online-tools/tsql-code-formatter
Friday, October 11, 2013 4:46 AM -
Thanks for the information! I want to add one more tool to this list - I use SQL Formatter to make my code better. This is an online serviceWednesday, August 15, 2018 8:19 AM