Sesame
Sesame

Reputation: 3410

#region functionality in SSMS 2008

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?

Upvotes: 16

Views: 15174

Answers (5)

CodingYoshi
CodingYoshi

Reputation: 27039

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

Upvotes: 4

Andrei Rantsevich
Andrei Rantsevich

Reputation: 2945

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.

Upvotes: 3

DataMaster
DataMaster

Reputation: 161

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/

Upvotes: 11

Carlos Muñoz
Carlos Muñoz

Reputation: 17824

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

Upvotes: 9

mrdenny
mrdenny

Reputation: 5078

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

Upvotes: 0

Related Questions