#region functionality in SSMS 2008

Viewed 13355

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?

5 Answers

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
Related