I’m a forty-something Microsoft SQL Server DBA of 15+ years, a devoted husband, and a father of three young boys. I have been a DBA at a public university, at a major bank, at a healthcare system, and I now work as a remote DBA with customers across the United States. I write and speak primarily about the tips and tricks that I discover along my SQL Server journey.
While 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!