LinkedIn | FaceBook | Twitter
In SQL Server Management Studio 2008, whenever you have a "block" of code (BEGIN....END, etc) SSMS will put a little plus-sign in the margin and allow you to "collapse" that block of code so you only see the BEGIN, not stuff underneath. If you're working with a really large set of code, that's helpful.
But I got an e-mail from a friend that said her SSMS didn't do that. I was kind of surprised, since I never had to do anything to make it work. We did a little digging, and come to find out it is in fact an option. Of course, we couldn't make it easy to find :) so I thought I would let you know where that option is in case you want to turn it off or back on (default, by the way, is on):
From the menu bar open Tools | Options
Open Text Editor | Transact-SQL | Intellisense (Yes, Intellisense. I have no idea why it is there. Just open it)
Then click the checkbox next to "Outline Statements" (No, I also have no idea why it is called that. I guess "Code Collapse" was too easy and wouldn't give me any material for a blog post)
Close everything out and re-open. Ta-da! By the way, this option is documented in Books Online, but not like this. Just thought you should know.
There's an adding for 2005 that adds collapse: http://www.ssmstoolspack.com/
Nifty toolpack it is.
Nice feature... I use it all the time! I think they called it outlining because Visual Studio also uses that terminology already for the same feature.
thx for the information..
but in my SSMS..
this feature only work at all comments, so i can use this to collapse n expand my own script (begin end, long select code etc...)
can u give any tips so i can use this feature for my script??
Please vote up for the bug "Plus (+) and minus (-) sign on left of editor which is used to Collapse/Expand Code Blocks disappears when SQLCMD Mode is enabled in SQL Server Management Studio"
I have SSMS 2008 R2
DB Server is SQL Server 2008.
I have "Outline Statements" checked.
but I do not have this feature.
It would be nice to be able to collapse / expand these code blocks via keyboard shortcuts... Visual Studio does it, I believe is Ctrl-M-M, Ctrl-M-L and Ctrl-M-O.
was it taken out in r2?
it seems to show outlines when i open my sql fileon SQL 2008 server's query window but doesnt on my R2 machine's window
Can't tell you how many times I've gone to select a line or lines of code and accidentally collapsed a bunch. Not a huge deal but I'm so glad to have an out! THANK YOU!
Thank you for the tip (on how to turn this *off*)!
Coming from the SQL200 world, I'm not quite ready for this feature yet...