How do I fix "incorrect syntax near GO" errors in scripts generated with Microsoft's Database Publishing Wizard? How do I fix "incorrect syntax near GO" errors in scripts generated with Microsoft's Database Publishing Wizard? database database

How do I fix "incorrect syntax near GO" errors in scripts generated with Microsoft's Database Publishing Wizard?


From the docs:

GO is not a Transact-SQL statement; it is a command recognized by the sqlcmd and osql utilities and SQL Server Management Studio Code editor.

Either use such a tool to execute the script or omit the GO commands.


I ran into the same problem recently and found the right answer to it (I think).

If you create a query in some random editor other than SQL Server Management Studio Code editor at the end of a line you may get a CARRIAGE RETURN (\r) character instead of a CARRIAGE RETURN + LINE FEED (\r\n). And even if you hit the DEL key at the end of the line and then Enter it doesn't change.

Use Notepad++ to replace CR (\r) for CRLF (\r\n) - keep the order, it's important!