http://www.sqlservercentral.com/blogs/nebraska-sql-from-dba_andy/2012/03/12/double-dash-comments-the-hidden-menace/ Printed 2014/07/29 02:04PM
Double-Dash Comments, the Hidden MenaceWhile writing my last post on cleaning up old maintenance plans, I was reminded of something I heard in a presentation once (and unfortunately I can't remember who said it) that has stuck with me for the last several years:
Word Wrap is Your Enemy.
Why is this? If you use double-dash inline comments:
--This is a comment, at least it is supposed to be.SELECT COL01, COL02, from dbo.mytable
...and your code gets opened in Notepad/Wordpad or some other editor that utilizes Word Wrap, it could look like this:
--This is a comment, or at least it is sup
posed to beSELECT COL01, COL02, from dbo.mytable
Good luck executing that code after it has been copy-pasted in this format into a query tool....something like "Improper syntax near 'posed'"
Even if you don't try to execute it, it can be difficult to read and troubleshoot when similar pieces of code are near each other and one line or the other is double-dash commented out.
So the hint to this is always, always, ALWAYS use star-slash comments /* */ even if your comment is short (even a single word) - it's not a bad habit to get into and doesn't cost you much (two extra characters) to protect you from this problem.
/*This is a comment, or at least it is sup
posed to be (and still is!)*/SELECT COL01, COL02, from dbo.mytable
Hope this helps!