SSMS 2008 中的#region 功能

发布于 2024-09-11 04:26:29 字数 187 浏览 7 评论 0原文

使用Sql Server 2008,Visual Studio中有类似#region的功能吗?

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

虽然这接近我想要的,但我想知道是否有一种方法可以定义一段代码,无论语法如何,类似于#region/#endregion。

有什么想法吗?

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

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.

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.

Any thoughts?

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

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

发布评论

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

评论(5

倦话 2024-09-18 04:26:29

是的,SSMS 2008 中有本机支持,无需任何插件。
区域定义如下:

  1. 从第一个 GO 命令到下一个 GO 命令。
  2. BEGIN – END、BEGIN TRY – END TRY、BEGIN CATCH – END CATCH 之间的语句
  3. 多行语句

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

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

  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

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

醉梦枕江山 2024-09-18 04:26:29

SSMS 有一个名为 SSMS 工具包 的插件。
它允许您使用 #region / #endregion http://www.ssmstoolspack.com/Features?f= 9

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

执笔绘流年 2024-09-18 04:26:29

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

--#region [name]
--#endregion

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

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

--#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.

烟酒忠诚 2024-09-18 04:26:29

我刚刚破解了 beginend 来创建区域,如下所示:

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

我总是确保将 --region 放在 < code>begin 和 end 因此它们从真正的 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

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

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 --region beside the begin and end so they stand out from real begin and end blocks. For example:

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
无声情话 2024-09-18 04:26:29

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

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

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