SQL import problem

[expired user #8614]'s profile image [expired user #8614] posted 10 years ago in General Permalink
I am trying to import SQL scripts by going to File --> Load SQL File ... and then selecting my sql script. The script loads in a new query window but when I press F9 I get the following error message.

/* Loading file "C:\Users\Me\Desktop\refscan.sql" (4.7 KiB) into query tab #2 ... */
CREATE DATABASE IF NOT EXISTS "refscan";
/* SQL Error (102): Incorrect syntax near the keyword 'IF'
Incorrect syntax near 'refscan'. */
/* Affected rows: 0 Found rows: 0 Warnings: 0 Duration for 0 of 13 queries: 0.000 sec. */


If I use Heidi SQL to export a database and then try to import it back I get the same problem.

Where am I going wrong?
ansgar's profile image ansgar posted 10 years ago Permalink
I guess you are not importing into a MySQL database, right?

Apart from that, if it's MySQL, your database name refscan is quoted with doublequotes, which is not supported by MySQL (as long as you don't have ANSI mode on). You need to use backticks:
CREATE DATABASE IF NOT EXISTS `refscan`;
[expired user #8614]'s profile image [expired user #8614] posted 10 years ago Permalink
Thanks for the reply. It is a MS SQL Express database.

I get the same problem if I export an existing database using Heidi SQL. I cannot then import that file using Heidi SQL as I get the same errors.
ansgar's profile image ansgar posted 10 years ago Permalink
Export SQL syntax is currently quite MySQL-specific. The myriad of differences in the SQL dialects between RDBMS makes it nearly impossible to create sql files which work on all supported systems.
[expired user #8614]'s profile image [expired user #8614] posted 10 years ago Permalink
Thankyou ansgar. I manually edited the file and was able to get it to work.

Great product.

Please login to leave a reply, or register at first.