I have an auto-generated SQL script with this basic structure:
/*
*/
PRINT 'Stuff'
GO
/*
*/
PRINT 'Other stuff'
The problem is that SQL Server doesn’t seem to like block comments when they are placed after a GO. There is a bug for this on Connect (set to won’t-fix, sigh) and a guy named Devi posted some workarounds, but they don’t really work for me because my script is auto-generated.
I can insert something after the GO and before the second block comment. I’ve tried various things in there, however, without changing the failing outcome which, fwiw, is this helpful text:
Msg 102, Level 15, State 1, Line 1 Incorrect syntax near ”.
Is there anything I can stick in between the GO and the comment to avoid this error?
Your issue seems to be of a different nature, and two things point to that.
The linked Connect page is about
/* ... */comment afterGOon the same line with it, but in your case the comment starts on the line that followsGO.The issue you are alluding to produces this error message:
But yours is different:
I’m going to guess here (but not unreasonably, I hope) that your script generator uses Mac style line breaks (
0x0D) instead of Windows style ones (0x0D0A). I was able to almost reproduce the issue using Mac line breaks, but in my case the error was just a little bit different from yours:Still it seems close enough for me to suggest you check what kind of line breaks your script generator uses.