visual-studio SSMS 2008 中的#region 功能

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3339631/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 12:15:31  来源:igfitidea点击:

#region functionality in SSMS 2008

sqlsql-servervisual-studioregion

提问by Sesame

Using Sql Server 2008, is there any functionality similar to #region in Visual Studio?

使用 Sql Server 2008,是否有任何类似于 Visual Studio 中#region 的功能?

I'm aware that nodes appear to allow collapsing of SQL segments, but as far as I know, this is based on the syntax of the SQL statement.

我知道节点似乎允许折叠 SQL 段,但据我所知,这是基于 SQL 语句的语法。

While that is close to what I'm after, I'm wondering if there is a way to define a section of code, regardless of syntax, similar to #region/#endregion.

虽然这与我所追求的很接近,但我想知道是否有一种方法可以定义一段代码,而不管语法如何,类似于 #region/#endregion。

Any thoughts?

有什么想法吗?

采纳答案by Carlos Mu?oz

There is an add-in for SSMS called SSMS Tools Pack. It lets you use #region / #endregion http://www.ssmstoolspack.com/Features?f=9

有一个名为SSMS Tools Pack 的SSMS 加载项。它允许您使用 #region / #endregion http://www.ssmstoolspack.com/Features?f=9

回答by sql xdetails

Yes, there is native support in SSMS 2008 on, without any addins. The regions are defined by:

是的,在 SSMS 2008 上有本地支持,没有任何插件。区域定义为:

  1. From first GO command to next GO command.
  2. Statements between BEGIN – END, BEGIN TRY – END TRY, BEGIN CATCH – END CATCH
  3. Multiline statements
  1. 从第一个 GO 命令到下一个 GO 命令。
  2. BEGIN – END、BEGIN TRY – END TRY、BEGIN CATCH – END CATCH 之间的语句
  3. 多行语句

See examples here: http://blog.sqlauthority.com/2009/06/28/sql-server-2008-management-studio-new-features-2/

请参阅此处的示例:http: //blog.sqlauthority.com/2009/06/28/sql-server-2008-management-studio-new-features-2/

回答by Andrei Rantsevich

I develop SSMSBoost add-in (www.ssmsboost.com) for SSMS and have added

我为 SSMS 开发了 SSMSBoost 插件 (www.ssmsboost.com) 并添加了

--#region [name]
--#endregion

syntax support in last version (2.12). There is also an option to auto-parse opened files, so that regions will be displayed immediately.

上一版本 (2.12) 的语法支持。还有一个选项可以自动解析打开的文件,以便立即显示区域。

回答by CodingYoshi

I have just been hacking the begin, endto create regions as shown below:

我刚刚破解了begin,end以创建如下所示的区域:

begin--region Getting top 5 Employee records
    select top 5 * from dbo.Employee order by Salary;
end--region Getting top 5 Employee records

I always make sure to put the --regionbeside the beginand endso they stand out from real beginand endblocks. For example:

我总是确保将它们放在--region旁边beginend这样它们就可以从真实beginend块中脱颖而出。例如:

if (1=1)
begin
    begin--region Getting top 5 Employee records
        select top 5 * from dbo.Employee order by Salary;
    end--region Getting top 5 Employee records
end

回答by mrdenny

No there's not. It only is done at the statement level.

不,没有。它仅在语句级别完成。