0

I have large .sql files exported from MySQL, and try to import them to MS SQL(localDB) via

SQLCMD. But when I type in the following into Command-prompt:

sqlcmd.exe -S (localdb)\MSSQLLocaldb -i C:\Users\Administrator\Desktop\1\SQLQuery4.sql

I got the following error message:

Incorrect syntax near 'tblo'

I checked my .sql file, it seems SQLCMD can't understand double quotes

e.g.

INSERT INTO "tblo" VALUES (2,'DTT','10000286','Dp','y',2,38,'2010-02-22 11:03:51','2010-02-22 11:03:51');

However, it's fine with SSMS

Any idea to solve this problem?

2
  • You can not Import an mysqldump directly to mssql Commented Apr 7, 2017 at 8:40
  • Not exactly. If I perform these .sql file in SSMS, I can import successfully. And I found if I remove double quotes in these, I also can import by SQLCMD. But it's too inconvenience. So I'd like to know is any possible to let my SQLCMD understand double quotes. Commented Apr 7, 2017 at 13:43

1 Answer 1

1

I found a solution by myself: I can add --skip-quote-names flag when I dump data from MySQL

e.g.

mysqldump.exe -hlocalhost -uUserName -pPassword --compatible=mssql --no-create-info --skip-quote-names --skip-add-locks DataBase tblo > D:\Test\dump.sql

Result in dump.sql will be like:

INSERT INTO tblo VALUES (2,'DTT','10000286','Dp','y',2,38,'2010-02-22 11:03:51','2010-02-22 11:03:51');

So I can use this .sql to directly import data into MS SQL server via SQLCMD

sqlcmd -S (localdb)\MSSQLLocaldb -i D:\Test\dump.sql

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.