Академический Документы
Профессиональный Документы
Культура Документы
Page 1 of 5
Database » Database » SQL Server Beginner License: The Code SQL, Windows, SQL Server (SQL
Project Open License (CPOL) 2005)
Introduction
This article is describing few simple steps in order to migrate a MySQL into Microsoft SQL Server
2005. The technique is very easy, but useful if you plan to move your data from MySQL and
upgrade it finally to an MS SQL Server enviroment.
Background
Initially I started my search for an article in Codeproject regarding MySQL->MS SQL migration
without any success. I had an old PHPbb forum running, that needed to be upgraded to a
Microsoft enviroment entirely. I could have just kept MySQL and Apache server, but instead I
decided to migrate the entire concept of PHPbb to a YAF-forum.
• Open your ODBC Data Source Administrator from the Control Panel -> Administrative
Tools. Under the tab labeled as "System DSN" press the "Add" button.
http://www.codeproject.com/KB/database/migrate-mysql-to-mssql.aspx?display=Print 11/5/2009
CodeProject: Migrate MySQL to Microsoft SQL Server. Free source code and programmi... Page 2 of 5
• On the "Create New Data Source" dialog that appeared, choose MySQL ODBC 5.1 Driver
and then press the "Finish" button.
• After that a MySQL connection configuration dialog will appear. Add your MySQL database
account information in it, preferably the "root" account which has full access to your
databases in MySQL. In this case my database is called "tigerdb". Do not change the port
to anything else then 3306, unless during your MySQL server installation have defined
something else.
http://www.codeproject.com/KB/database/migrate-mysql-to-mssql.aspx?display=Print 11/5/2009
CodeProject: Migrate MySQL to Microsoft SQL Server. Free source code and programmi... Page 3 of 5
• Press the "Test" button to ensure your connection settings are set properly and then the
"OK" button when you're done.
EXEC master.dbo.sp_addlinkedserver
@server = N'MYSQL',
@srvproduct=N'MySQL',
@provider=N'MSDASQL',
@provstr=N'DRIVER={MySQL ODBC 5.1 Driver}; SERVER=localhost; DATABASE=tigerdb; USER=root;
This script will produce a link to your MySQL database through the ODBC connection you just
created on the previous stage of this article. The link will appear in the MS SQL Server
Management studio like this:
http://www.codeproject.com/KB/database/migrate-mysql-to-mssql.aspx?display=Print 11/5/2009
CodeProject: Migrate MySQL to Microsoft SQL Server. Free source code and programmi... Page 4 of 5
Thats it!
Points of Interest
During this migration I had to import lately my newly migrated database into the structure of
"Yet Another Forum" tables. For that I used a series of SQL-scripts. However I am not going to
post them here. If folks leave comments here about the need to these script, just tell me and I
will gladly change this article and start adding them. You're welcome to post your comments.
Another issue you will most likely encounter are the differences between these two databases
based on datatypes. I would suggest to proceed with a reverse engineering of your MySQL
database (for example, Visio is one application that provides reverse engineering functionality)
and start mapping all the differences and potential risks of loosing parts of data for instance,
within varchar columns.
http://www.codeproject.com/KB/database/migrate-mysql-to-mssql.aspx?display=Print 11/5/2009
CodeProject: Migrate MySQL to Microsoft SQL Server. Free source code and programmi... Page 5 of 5
History
2008-09-05: First version of this article.
License
This article, along with any associated source code and files, is licensed under The
Code Project Open License (CPOL)
http://www.codeproject.com/KB/database/migrate-mysql-to-mssql.aspx?display=Print 11/5/2009