Andy
Andy

Reputation: 3743

Import into SQLServer an SQL file exported from MySql

I have a rather large .sql file (100s of MB) created by MySQL, and I need to import it in SQLServer (Express, 2019). It keeps failing due to various syntax errors.

Is there a way to make it compatible enough so SQLServer accepts it? I don't even need 100% accuracy, so minor data losses like very long strings, weird character combinations or even relationships can be dropped as long as it imports all tables and text data.

Edit: I do not have access to the original database, the *.SQL file is all there is. Also, editing the script manually is not an option, due to the size of the file. This question is NOT a duplicate

Upvotes: 1

Views: 150

Answers (1)

Bill Karwin
Bill Karwin

Reputation: 562230

As mentioned in the comment above, another option is to import your .sql file to MySQL on your current computer, and then you can use other means to transfer the data. For example: https://learn.microsoft.com/en-us/sql/sql-server/migrate/guides/mysql-to-sql-server?view=sql-server-ver16

If you don't want to use MySQL, and you don't have access to the original database, then you must modify the .sql somehow. I don't believe there is a Microsoft SQL Server mode that accepts all MySQL syntax.

You said editing the file is not an option. That's false, there are editors that can handle files similar in size to the one you describe. See Text editor to open big (giant, huge, large) text files

I would use sed, the stream editor, which can literally handle infinite input.

You don't have to account for all MySQL syntax, just the cases that occur in your input file.

Upvotes: 1

Related Questions