I was recently participating in a forum and came across an interesting question. What attracted my attention was that the person was trying to keep their T-SQL code clean and readable (which in itself is a rare sight).
The person was trying to group their T-SQL code into regions. In the world of application development technologies (e.g. C#) we would typically use the #region….#endregion combination. However, it does not work with T-SQL because the hash (#) is used to define temporary tables.
In T-SQL, the basic control-of-flow statements that allow you to group the code are the BEGIN…END keywords. The BEGIN…END keywords can be used to logically group code so that they can be collapsed or expanded as required.
The BEGIN…END keywords are therefore the functional equivalents of the #region…#endregion statements.
Until we meet next time,
Be courteous. Drive responsibly.
Pingback: #0409 – SQL Server – Code Blocks – Equivalent of #region…#endregion - SSWUG.ORG