There are two ways you can write comments in T-SQL:
–By starting a line with two dashes, or /* By framing it on both sides like this */
Never, ever use two dashes. Never.
The problem is that monitoring tools and diagnostic management views often dump out the T-SQL in one long line. So this query:
SELECT * FROM dbo.Users WHERE DisplayName = N’Brent Ozar’ — This line is a comment AND Location = N’Iceland’ ORDER BY Reputation DESC;
Becomes this:
SELECT * FROM dbo.Users WHERE DisplayName = N’Brent Ozar’ — This line is a comment AND Location = N’Iceland’ ORDER BY Reputation DESC;