Search code examples
sql-servert-sqlsql-server-2008

Database - how to create regions in TSQL (SQL Server 2008)


Is there a way to create collapsible regions in the SQL script file like we create in Visual Studio using #region ..... #endregion?

The script file contains DDL statements, like Alter Table, Alter View, etc. and i want to group them in regions like "Table Related Statements", "View Related Statements", etc.


Solution

  • Yes, with SSMS Tools Pack

    Regions and Debug sections

    Regions behave in the same way as in Visual Studio. You can collapse them and expand them. Debug sections are sections that get commented when you change your script to Release configuration. A debug section is also a collapsable region. If you deploy a script in debug mode with added debug sections it will fail when run from SSMS without SSMS Tools Pack installed. You can of course comment those sections yourself by simply searching for start and end text of the debug sections