“全部折叠”或“切换轮廓”在 SQL Server Management Studio 2008 中

发布于 2024-08-13 17:50:18 字数 178 浏览 2 评论 0原文

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

A new feature in SQL Server Management Studio 2008 is 'outlining' (the ability to collapse regions). It is awesome. However, by default all regions are expanded. I can't seem to find a way to 'collapse all' (also called 'toggle outline' in Visual Studio). Is anyone aware of a way to do this? I've been tasked with reviewing a 3,000 line stored procedure, and collapsing regions one-by-one is cumbersome.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(11

我不是你的备胎 2024-08-20 17:50:18

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

打开您的查询,然后转到“编辑”>“概述>切换所有大纲。

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

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.

贱人配狗天长地久 2024-08-20 17:50:18

看来这个功能不存在。已推荐给微软。我建议投票赞成;
http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx ?FeedbackID=368542

作为解决方法,我使用 Notepad++ 在本地进行编辑。它的区域识别性不太好,但总比没有好。

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.

拿命拼未来 2024-08-20 17:50:18

解决方法是使用 BEGIN 和 END。

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

/*

TSQL goes here

*/

END

然后您将能够折叠 BEGIN。

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.

鲸落 2024-08-20 17:50:18

在 ssms 2017 ->工具>中有一个选项选项{参见图片}

下面说明了 @Triynko 对 @Shawns 答案的更新

在此处输入图像描述

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

The below illustrates @Triynko update to @Shawns answer

enter image description here

秋日私语 2024-08-20 17:50:18

SSMS 有一个免费的第 3 方插件,称为 SSMS Tools Pack。它提供了一些有用的功能,其中包括可折叠区域和调试部分。默认情况下,当您首次打开 .sql 脚本时,区域会折叠。

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

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
遇见了你 2024-08-20 17:50:18

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

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

池木 2024-08-20 17:50:18

在我的情况下,“最大脚本大小”默认为 1MB,我的是 1Mb 以上,将其更改为 5MB,它可以工作

路径是

“工具”>>选项>>文本编辑器>> TransactSQL>>智能感知>>最大脚本大小

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

笙痞 2024-08-20 17:50:18

我发现有用的选项...

Edit.ToggleAllOutlined

在 SSMS 2019 ->工具>选项>环境>键盘,然后单击命令 Edit.ToggleAllOutlined 并分配新的快捷键。
选项屏幕截图

警告截图

我使用了 Ctrl+K、Ctrl+T。

然后在 Query 的开头放置一个 GO,并在我想要折叠的任何区域之后放置 GO。我尝试了 BEGIN END,但它折叠了整个查询。

请尝试以下操作:

/*
Toggle using Tools > Options > Environment > Keyboard
Search for "Toggle"
Select Edit.TogleAllOutlining
Enter Global Shortcut key.  Do not use common keys like ctrl-A, ctrl-c, ctrl-v, etc...
    Pay attention to "Shortcut currently used by: (dropdown values)"

I used ctrl-k, ctrl-t
*/  
GO

    --Do something
    Declare @Something varchar(max)
GO
    /*First Region*/    
    select 'parent - this will be toggled'
    
    select 'sub query - toggled with parent'
GO
    /*Second Region*/   
    select 'parent - this will be toggled too'
    
    select 'sub query - toggled with parent'
GO

An option that I found helpful...

Edit.ToggleAllOutlining

In SSMS 2019 -> Tools > Options > Environment > Keyboard, then click on command Edit.ToggleAllOutlining and Assign your new shortcut keys.
Screenshot of Option

Screenshot of Caution

I used Ctrl+K, Ctrl+T.

Then put a GO in the beginning of Query and GO after any region I wanted collapsed. I tried BEGIN END, but it collapsed entire Query.

Try it out with the following:

/*
Toggle using Tools > Options > Environment > Keyboard
Search for "Toggle"
Select Edit.TogleAllOutlining
Enter Global Shortcut key.  Do not use common keys like ctrl-A, ctrl-c, ctrl-v, etc...
    Pay attention to "Shortcut currently used by: (dropdown values)"

I used ctrl-k, ctrl-t
*/  
GO

    --Do something
    Declare @Something varchar(max)
GO
    /*First Region*/    
    select 'parent - this will be toggled'
    
    select 'sub query - toggled with parent'
GO
    /*Second Region*/   
    select 'parent - this will be toggled too'
    
    select 'sub query - toggled with parent'
GO
離人涙 2024-08-20 17:50:18

Ctrl+M、Ctrl+A 是 SSMS 17.X 中的默认设置。

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

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.

盛夏尉蓝 2024-08-20 17:50:18

CTRL + M 然后 CTRL + L

全部在 Visual Studio 2022 中折叠/展开

CTRL + M then CTRL + L

collapse / decollapse all in visual studio 2022

忘羡 2024-08-20 17:50:18

此功能已在 SQL Server Management Studio 2012 中实现,并且可用于除使用 CTRL + M 等之外的版本 - https://msdn.microsoft.com/en-us/library/ms174205(v=sql.110).aspx

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文