Double hyphens following newline not treated properly


the string
is treated as an unterminated string followed by a comment. this should be treated as

file attachments

Closed Mar 26, 2012 at 10:26 AM by ErikEJ released


ErikEJ wrote Dec 15, 2011 at 7:21 AM

That seems to be an edge case - and what about the 2 hyphens?

wrote Dec 15, 2011 at 11:00 AM

Fixed on changeset 83907

wrote Dec 15, 2011 at 11:00 AM

lostinplace wrote Dec 15, 2011 at 2:25 PM

the line should have been N'Hello'+NCHAR(10)+NCHAR(13)+'--Janet'

This is accounted for in the patch


wrote Jan 6, 2012 at 3:54 PM

mape1082 wrote Jan 6, 2012 at 3:54 PM

This patch is causing an issue when the SQL sentence is big enough:

Msg 191, Level 15, State 1, Line 1
Some part of your SQL statement is nested too deeply. Rewrite the query or break it up into smaller queries.

The insert statement looks like the attachments, being 190+ lines long.

The solution I found was:
to replace "'+NCHAR(10)+NCHAR(13)+'" by ""..

A more long term solution may be neeed.

lostinplace wrote Jan 6, 2012 at 5:33 PM

Can you clarify please?

lostinplace wrote Jan 6, 2012 at 5:35 PM

I would imagine that this is occurring because of the large number of newlines (and hence extremely complex sql statement)

can you clarify your solution?

mape1082 wrote Jan 7, 2012 at 4:39 AM

Sorry for the delay. The issue was solved by removing the call to NCHAR(10) and NCHAR(13) and replacing the \n by an empty string "". This worked with my dataset by may not work for others. Since it is removing the functionality introduced by the patch I wouldnt say mine is a solution.

Maybe in the specific case of the issue addressed by the patch, the solution could be as follows:

if a string contains "\n" followed by "--", then it could be replaced by "\n-' + NCHAR(??)", where ?? is the ascii code for the '-' charcater. If this patch was like this it would work too with my dataset.


ErikEJ wrote Jan 8, 2012 at 1:16 PM

Setting to active, and rollong back fix for now

wrote Feb 10, 2012 at 9:53 PM

Fixed on changeset 86293

wrote Feb 10, 2012 at 9:53 PM

wrote Mar 26, 2012 at 10:26 AM

wrote Feb 22, 2013 at 12:14 AM

wrote May 16, 2013 at 11:59 AM