How to add better comments into SQL server

Whilst I'm firmly in the 'Tried and Test' camp for most things in life and I may only be new to SQL programming but there are just sometimes when I have to buck the mainstream trend and do it my way.

One of these occasions is comments in SQL, the widely adopted way would be to use the prescribed double dash -- or the widely adopted across multiple languages slash-star:

-- comment here
/* another type of comment */

However in this instance I'm going to declare my way is best! I put my comments into a print statement (not in the middle of the code obviously)

Print'Comment here'
Then code

Not only does it stand out better in your code editor's syntax highlighter but it makes the messages log more verbose when you are debugging or reconciling record numbers throughout your scripts.

Tags : SQL comment code

Search Posts

Back to top