“collapse all' or ”toggle outline\" in SQL Server Management Studio 2008

人走茶凉 提交于 2019-12-03 23:53:45

It appears this feature does not exist. It has been recommended to Microsoft. I suggest voting it up; http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=368542

As a work-around, I'm using Notepad++ to edit locally. Its region identification isn't as good, but it's better than nothing.

This isn't a shortcut key, but there is a menu option in the Query Editor to do this.

Open your query and then go to Edit > Outlining > Toggle All Outlining.

This will toggle (i.e. expand/collapse) all nodes in the query.

Eric Russell

There is a free 3rd party add-in for SSMS called, SSMS Tools Pack. It provides several useful features, which includes collapsable regions and debug sections. By default, the regions are collapsed when you first open a .sql script.

http://www.ssmstoolspack.com/Features?f=9

For example:

--#region You can place comments here which are visible when the region is collapsed.

if object_id('MyTable') is null
begin
   create table MyTable 
   (
   constraint [pk_mytable] primary key clustered ( mytable_id ),
   mytable_id int not null  
   );
end;

--#endregion
Willem Jac

A workaround is to use BEGIN and END.

BEGIN -- comment on/explain the region/outlined section

/*

TSQL goes here

*/

END

You will then be able to collapse the BEGIN.

In ssms 2017 -> There is an option in Tools > Options {see image}

The below illustrates @Triynko update to @Shawns answer

If you open a .sql script in Visual Studio then you can collapse the code in there.

This feature was implemented in SQL Server Management Studio 2012 and is available for editions beyond also using CTRL + M etc - https://msdn.microsoft.com/en-us/library/ms174205(v=sql.110).aspx

Ctrl+M,Ctrl+A is the default in SSMS 17.X.

You can change this by going to Tools > Options > Environment > Keyboard, then click on command Edit.CollapseAllOutlining and Assign your new shortcut keys.

In my condition it was "Maximun Script Size" default is 1MB, mine was above 1Mb changed it to 5MB it works

Path is

Tools >> Options >> Text Editor >> TransactSQL >> Intellisense >> Maximum Script Size

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!