Sybase: Incorrect syntax near ‘go’

If you execute a bunch of SQL statement from a shell script (e.g. to create tables/procedures) and get the following error message:

Msg 102, Level 15, State 1:
Server ‘SYBASE’, Procedure ‘xxxxxx’, Line xx:
Incorrect syntax near ‘go’.

But it all works fine when executing it in an SQL client (like SqlDbx or ASEIsql), the problem is probably related to the end of line. If you create the SQL file executed by the script on a Windows machine, it will end the lines with Carriage Return and Line Feed (CR+LF) and on a Linux/Unix system, it should only be a Line Feed (LF). After converting the file to Unix format, it should not see the error anymore.

Under Linux, you can convert the file using:

# tr -d '\r' < inputfile > outputfile

or:

# sed -e 's/\r$//' inputfile > outputfile

or:

# dos2unix inputfile

Leave a Reply

Your email address will not be published.