Home Dashboard Directory Help
Search

[SSMS] "Format Document" in SSMS by Jamie Thomson


Status: 

Closed
 as By Design Help for as By Design


46
0
Sign in
to vote
Type: Suggestion
ID: 496617
Opened: 10/8/2009 6:32:06 AM
Access Restriction: Public
2
Workaround(s)
view

Description

I often have to copy/past generated code into SSMS (quite often its the SQL that Analysis Services generates from its DSV that I get from Profiler) and I have to spend time reformatting the SQL into a form that makes it easy to read.
Details
Sign in to post a comment.
Posted by AaronBertrand on 6/21/2013 at 3:40 PM
This document:

http://msdn.microsoft.com/en-us/library/ms174205.aspx

Says for Ctrl+K, Ctrl+D:

Applies the indenting and space formatting for the language specified on the Formatting pane of the language in the Text Editor section of the Options dialog. Available only in the text editor.

Until you fix this, it should say:

Applies the indenting and space formatting for the language specified on the Formatting pane of the language in the Text Editor section of the Options dialog. Available only in the text editor *** and only for specific languages ***.

Why you support XML here but not Transact-SQL here is beyond me.
Posted by Mark Wojciechowicz on 11/7/2012 at 6:20 AM
It has been 3 years and there is still no tooling added for the release of SQL 2008 R2 or SQL 2012. Why is this issue closed?
Posted by Microsoft on 5/10/2011 at 4:36 PM
Hi Jamie,
Thanks very much for taking the time to write in (and to everyone else, thanks for the up votes). We are taking this feature request seriously and considering it for an upcoming release.

Thanks,
-Sam Hughes
Posted by saurabh9 on 10/7/2010 at 5:13 AM
I see this a very important suggestion and this is what I had come to log here. it is now high time that SSMS had its own code auto format option like CtRL+K+D of Visual Studio. This also helps in Diff in version control, apart from making a query/SP more readable.
Posted by Jamie Thomson on 8/24/2010 at 2:41 AM
AReasonableMan stated that there could be options available for this. I agree, and some things you may want to consider are options to:
-Put commas at the beginning or end of rows
-Put each column/where predicate on a different line
-Indent using spaces or tabs
-Put the ON clause on a different row from the JOIN clause
Posted by Microsoft on 2/16/2010 at 1:23 AM
Hello,

Thank you for this feedback.

SQL formatting is indeed a feature we are considering in SSMS for the next major release.

Thanks,
Prashant Choudhari.
(prashant.choudhari@microsoft.com)
SDM-Dev
Posted by Valentino Vranken on 12/10/2009 at 3:05 AM
Hello Jamie,

Your suggestion has just scored another vote. I can really use this feature when designing SSRS reports on cubes, if only to decently format the one-line MDX query that the Query Designer fabricates! (I usually start my query by building it in the designer and then customizing it further in SSMS.)

Regards,
Valentino.
Posted by ZackOJones on 11/24/2009 at 12:42 PM
No doubt this would be a great feature for SSMS, especially if it is bound to the same Ctrl-K, Ctrl-D sequence that Visual Studio uses.
Posted by corydeppen on 10/12/2009 at 4:56 AM
Visual Studio has Format Document and Format Selection options... only seems natural to include in SSMS as well.
Posted by notalreadytaken on 10/10/2009 at 5:11 PM
I definitely agree. And, if there are a few formatting options that people could select among, the formatting would probably satisfy 95% of reasonable styles.

The main point is that consistent formatting makes other people's code (and your own after a while) much easier to read and debug.
Sign in to post a workaround.
Posted by AndreiRantsevich on 7/24/2012 at 5:04 AM
Free add-ins like
SSMSBoost or Thao Clerk's formatter solve this issue
Posted by Merrill Aldrich on 11/24/2009 at 8:25 AM
Commercial code prettifiers can be plugged into SSMS (at some cost)