Click here to Skip to main content
15,895,815 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Friends,
I have a requirement that i need to convert existing data from mysql to sqlserver.
Existing data of mysql is in the format of .sql file and so i need to convert this to
sql server.

I use that script data and run in New Query Window but it shows some error that
some keywords of mysql are not present in sql server.

Please help me.....
Thanks in Advance..........
Posted

1 solution

You need to use the MySQL ODBC driver (be sure to download the appropriate version for your MySQL Database; the link is for version 3.51) to create a Linked Server to the MySQL Server, and then run a SQL query to copy your database, table by table. The query is (write the database name, server name, user and password specific to your server
SQL
EXEC master.dbo.sp_addlinkedserver @server = N'MYSQL', @srvproduct=N'MySQL', @provider=N'MSDASQL', @provstr=N'DRIVER={MySQL ODBC 3.51 Driver}; SERVER=127.0.0.1; DATABASE=Db_NAME; USER=myusername; PASSWORD=mypass; OPTION=3'


Then you’ll have to copy your database table by table. The code for one of the tables will be:

SQL
select * into MSSQL_DB_Name.dbo.TableName
from openquery(MySQL, 'select * from Db_Name.TableName')


Try this
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900