When you’re writing code, you have some options when it comes to leaving comments:
- Double dashes at the start of a line:
- Block quotes around a section of text:
/* Comment! */
- No comment whatsoever:
The problem with the double-dash method is that there’s no terminator for it. If you end up pasting the query from a DMV where it’s not all nicely formatted, it’s pretty likely going to end up all on a single line.
With a long enough query, it can be a real pain to scroll across looking for comments and separating them to a new line so you can run the query.
What really sucks is that tools that can automatically format T-SQL for you can’t handle this either. If I could just right click and solve the problem, I’d be talking about that instead.
So, please: If you’re going to put comments in your code, use the block quotes.
Thanks for reading!