tags:

views:

329

answers:

3

I get this error:-

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' at line 1

whenever I tried something like this:-

mysql> source /home/user1/sql/ddl.sql
mysql> source /home/user1/sql/insert.sql
mysql> source /home/user1/sql/cleanup.sql

The intresting thing is, this happen to each and every one of the sql scripts but only the first statement is corrupted. The rest of the statements in the script will run fine. I have worked around this by putting a dummy statement in every script.

Anyone had this problem before? I am completely stumped and checking Google hadn't helped yet. Thanks in advance.

+2  A: 

Your input files may contain a Unicode BOM, which is a bit of cruft that some programs such as Notepad place at the start of the file to indicate the file format.

Greg Hewgill
+6  A: 

A possibility is that the SQL files were written in Unicode with a BOM, which mysql cannot interpret.

That would explain the symptoms.

A solution is to open them in a decent editor and save them back without it.

Example in VIM:

Force BOM removal

:set nobomb

Save and quit

:x!
Vinko Vrsalovic
How do I correctly save the file without the BOM? I have tried using Visual Studio 2008, Notepad, SciTE, and vim to resave those files and they still give the same error.
wai
A: 

Great, VIP Editor show hidden code in the SQL Scripts and tnks for that you can delete the ' but you cannot see it using notepad.

Thank you!!!