... until the collector arrives ...

This "blog" is really just a scratchpad of mine. There is not much of general interest here. Most of the content is scribbled down "live" as I discover things I want to remember. I rarely go back to correct mistakes in older entries. You have been warned :)

2008-08-06

SQL Server Comments vs Line Terminators

If you use the '--' comment syntax in SQL Server, the comment extends to the end of the line.  The question is: what constitutes the end of the line.  It turns out that SQL Server does not count a single return character as the end of line, so the following line(s) might be gobbled up into the comment.

It would seem that lines that end solely with a return character wouldn't happen in practice, at least on Windows.  However, if can happen if you are using the combination of HTA, DOM, Javascript and ADO.  If you extract the text content of an HTML element using DOM, then line terminators that are expressed as \r\n on disk are converted to \r in memory.  It is necessary to fix up such line endings before feeding the string to ADO if the SQL text contains any '--' comments.

Blog Archive