#region functionality in SSMS 2008

Sesame picture Sesame · Jul 27, 2010 · Viewed 12.2k times · Source

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?

Answer

sql xdetails picture sql xdetails · Jan 24, 2014

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/