Code Region in Management Studio

In PowerShell ISE I am used to put the code in collapsable/expandable blocks with #region, but that is not direct possible in SQL Server Management Studio.

But this entry in stackoverflow gives a workaround: "sql server #region".
The precise details on how to configure Management Studio is given by Buck Woody in the elder blog post "Code Collapse and Expand Feature in SQL Server Management Studio 2008".
Actually Buck gives the whole workaround, but my search gave me stackoverflow first...

A short example:
BEGIN -- Region Title
END -- Region Title

If you put a space or two last in the region title the region collapse in a visual pleasant way.
I repeat the region title at the end of the block. Sometimes there are more than one screen full in one block, and this way I am reminded about the context of the END-line.

And it works fine in Management Studio 2014, also with SQL Prompt installed.


Priya Kannan said...

Excellent ! I am truly impressed that there is so much about this subject that has been revealed and you did it so nicely.
SQL Server Training in Chennai

Alex Turner said...

Thanks for this information, it's valuable for me. There are a lot of tools for working with SQL code and database management. Recently I have found the tool SQL Complete, it's pretty good, has advanced features and the price is affordable.