代码之家  ›  专栏  ›  技术社区  ›  Shawn McGough

SQL Server Management Studio 2008中的“全部折叠”或“切换大纲”

  •  22
  • Shawn McGough  · 技术社区  · 15 年前

    SQL Server Management Studio 2008中的一个新功能是“概述”(折叠区域的能力)。太棒了。但是,默认情况下,所有区域都会展开。我似乎找不到“全部折叠”的方法(在Visual Studio中也称为“切换大纲”)。有人知道怎么做吗?我的任务是检查一个3000行的存储过程,逐个折叠区域非常麻烦。

    8 回复  |  直到 7 年前
        1
  •  24
  •   Shawn McGough    15 年前

    似乎此功能不存在。它已被推荐给微软。我建议投票表决; http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=368542

    为了解决这个问题,我使用记事本++在本地进行编辑。它的区域识别能力不强,但总比什么都没有强。

        2
  •  18
  •   SqlGuy    8 年前

    这不是快捷键,但在查询编辑器中有一个菜单选项可以执行此操作。

    打开查询,然后转到“编辑”>“大纲显示”>“切换所有大纲显示”。

    这将切换(即展开/折叠)查询中的所有节点。

        3
  •  4
  •   Marc Bernstein    14 年前

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

    例如:

    --#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
    
        4
  •  3
  •   dimcookies    12 年前

    解决方法是使用开始和结束。

    BEGIN -- comment on/explain the region/outlined section
    
    /*
    
    TSQL goes here
    
    */
    
    END
    

    然后你就可以开始崩溃了。

        5
  •  1
  •   Christian    9 年前

    如果在Visual Studio中打开.sql脚本,则可以折叠其中的代码。

        6
  •  1
  •   Pakk    7 年前

    在SSMS 2017中,->工具中有一个选项>选项请参见图片

    下面说明了@triynko对@shawns答案的更新

    enter image description here

        7
  •  0
  •   Tom    9 年前

    此功能在SQL Server Management Studio 2012中实现,除使用ctrl+m等外,还可用于其他版本。- https://msdn.microsoft.com/en-us/library/ms174205(v=sql.110).aspx

        8
  •  0
  •   Anna    7 年前

    ctrl+m,ctrl+a是ssms 17.x中的默认值。

    通过转到“工具”>“选项”>“环境”>“键盘”,然后单击“命令”“编辑”。collapseAlloutlining并分配新的快捷键,可以更改此设置。