|
|
Comments and Discussions
|
|
 |

|
Saved me buying one of those convertor programs!
|
|
|
|

|
Thank you it helped me a lot...
|
|
|
|

|
You're most welcome
Niklas Henricson
|
|
|
|
|
|

|
Remember if you're using a 64 bit Windows environment that you need to create the System DSN using the 32 bit version of the DSN Administrator Tool. By default the control panel loads the 64 bit version.
32 bit version can be loaded from here...
c:\windows\syswow64\odbcad32
|
|
|
|

|
Hi
But I cannot find mysql odbc provider in c:\windows\syswow64\odbcad32.
Please help.
|
|
|
|

|
.... good stuff , however I am dealing with 70 tables here.
Maybe in a stored proc?
Cheers
Ricardo Casquete
|
|
|
|

|
I believe it's good to know that such migration can be done extremely quickly with a commercial application Full Convert Enterprise. It doesn't require ODBC drivers at all and is very fast.
Regarding search for equivalent datatypes - Full Convert automatically selects closest matching datatypes, even taking into consideration target database version. For example, date and time datatypes are introduced in SQL Server 2008 and not available in earlier versions. Also, Full Convert allows datatype (and many other things) customization.
|
|
|
|

|
Another tool to automate the migration is DBConvert for MySQL and MS SQL
It takes about 5-10 minutes to convert 1Million records.
Automatic views conversion between MS SQL and MySQL is available.
Dmitry
|
|
|
|

|
Hey
The first query workd fine, but when I test the linked server I get 7307 error.
Any idea how I solve it?
Thank you!
|
|
|
|

|
Hi,
Do i have first to create the table with its collumns and datatypes in my test database in SQL?
Or does this script migrate everything (table structure and data)?
Error message after the second script:
<<Msg 7303, Level 16, State 1, Line 1
Cannot initialize the data source object of OLE DB provider "MSDASQL" for linked server "MYSQL".>>
what did I do wrong?
modified 29 May '12 - 6:50.
|
|
|
|

|
I successfully complete all steps but last query not run.
mySql database name : emots.
Sqldatabase:testMySQL.
myQuery :SELECT * INTO testMySQL.dbo.shoutbox
FROM openquery(MYSQL, 'SELECT * FROM emots.shoutbox')
MSSQL version : 2005
ERROR:
OLE DB provider "MSDASQL" for linked server "MYSQL" returned message "[MySQL][ODBC 5.1 Driver][mysqld-5.0.45-community-nt]Table 'emots.shoutbox' doesn't exist".
Msg 7350, Level 16, State 2, Line 1
Cannot get the column information from OLE DB provider "MSDASQL" for linked server "MYSQL".
|
|
|
|

|
This query missing the semi colon, which is mandatory in mysql queries.
Use like this
SELECT * INTO testMySQL.dbo.shoutbox
FROM openquery(MYSQL, 'SELECT * FROM emots.shoutbox;')
|
|
|
|
|

|
Excellent Article. Still worth 5 Stars but there are known issues with SQL Server 2008 acknowledged by Microsoft. Anyone found a solution to the column u permissions error when you try to view the data in a table?
|
|
|
|

|
I've got a similar task to do, but at the opposite.
I need to syncronize a mySQL db with a SQL Server 2008 db.
These dbs contains some blob fields (varbinary(max) in SQL Server that in mySQL are MEDIUMBLOB), but when I run the INSERT statement, I receive this error:
Provider OLD DB "MSDASQL" for linked server XXX reply with the message "Query-based Insert and update statement are non supported for Blob values"
Any idea to resolve this?
Thans
|
|
|
|

|
Hi Niklas,
thanks for this nice article, almost everything went smoothly. But I do have a few questions:
1. In this script:
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; PASSWORD=hejsan; OPTION=3'
What does the option=3 stand for?
And now my real problem, where I need help with:
That's the script I'm running:
SELECT * INTO mysqlforum.dbo.shoutbox
FROM openquery(mysql, 'SELECT * FROM mysql')
In your own script the last line ends with FROM tigerdb.shoutbox, but that shoutbox part, I don't have that actually. My database is just called mysql.
When I run the script MSSQL 2008 gives me following error:
OLE DB provider "MSDASQL" for linked server "mysql" returned message "[MySQL][ODBC 5.1 Driver][mysqld-5.1.53-community-log]No database selected".
Msg 7350, Level 16, State 2, Line 1
Cannot get the column information from OLE DB provider "MSDASQL" for linked server "mysql".
What does this error means?
A bit of background information:
The mysql db I want to migrate is part of the WAMP server. I do have a second DB, it's the InformationSchema.
Any advice is appreciated.
Kind regards,
Jay
|
|
|
|

|
For all others, I could solve my problem as it was due to a few misunderstandings of the scripts above.
|
|
|
|

|
Hi!
I've got an error message when trying to select from MySql database:
Query:
SELECT * FROM openquery(INTERSPIRE2, 'SELECT * FROM send.ss_newsletters')
Error message:
OLE DB provider "SQLNCLI" for linked server "INTERSPIRE2" returned message "Login timeout expired".
OLE DB provider "SQLNCLI" for linked server "INTERSPIRE2" returned message "An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections.".
Msg 53, Level 16, State 1, Line 0
Named Pipes Provider: Could not open a connection to SQL Server [53].
What could be wrong?
Thanks in advence!
|
|
|
|

|
Mihaly Sogorka wrote: "An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections."
Like the message indicates you need to allow your SQL server, remote connections. Creation of database links are clasified as such. Go to your SQL Server Configuration Manager and check your settings, or look for help by searching at MSDN troubleshooting pages.
Niklas Henricson
|
|
|
|

|
I have run the script
EXEC master.dbo.sp_addlinkedserver
@server = N'MYSQL',
@srvproduct=N'MySQL',
@provider=N'MSDSQL',
@provstr=N'DRIVER={MySQL ODBC 5.1 Driver}; SERVER=localhost;DATABASE=test; PASSWORD=alam; OPTION=3'
But when I run the following script:
SELECT * INTO testMySQL.dbo.shoutbox
FROM openquery(MYSQL, 'SELECT * FROM test.aa')
I get the error:
Msg 7403, Level 16, State 1, Line 1
The OLE DB provider "MSDSQL" has not been registered.
So how Can I solve the problem?
Thanks in Advaance........
|
|
|
|

|
Hello,
It would seem that your MySQL ODBC provider was not installed properly. Either install a new one, or try by reinstalling it. This is pure installation and configuration issue I cannot help you much with.
Niklas Henricson
|
|
|
|

|
Thank you for sharing this with us, this is what I need now.
However, I stuck at the very beginning, when I try to install a new ODBC data source, I don't even see "MySQL ODBC 5.1 Driver" like in your second screenshot in the post.
What's missing here?
Thank you very much.
The email I registered for CodeProject is full of spam now, if you know how to fix it, could you please send me email at xie3208080 gmail com?
Thanks again and hoping to hearing from you soon.
|
|
|
|

|
At the time I was writing this article things have changed. Did you use the same environment I specify on the top of the article (SQL Server 2005, Win XP)? Try reinstalling your mySQL ODBC provider or download a newer one. If you are using Windows 7, Windows 8 alfa or any other newer operating system, configuration settings might be relocated.
Niklas Henricson
|
|
|
|

|
I want to migrate a full db into mssql express and so far I have done for one table. I have several tables and it would take a long time to do it and probabaly I'll do this with other databases as well. Could you direct me to a page where I can learn fast script for ms sql. Or show me the general way to loop through tables in a db?
Thanks
|
|
|
|

|
We have created an opensource database plugin for MySQL that allows to insert data directly in oracle from within MySQL. You can also do both, query oracle tables or insert/update/delete oracle table data just like a JDBC connector but without the need to do any Java/Perl/PHP code.
The plugin that I have written that is compatible Debian/Redhat/Windows platforms and MySQL 5.1.X and 5.5.X
The plugin works the same way as an MySQL Federated table or as a ORACLE DBLINK type of thing...
You create a table and you set the connection string to an Oracle, MySQL, MSSQL server and table name.
Feel free to try the MySQL Plugin at : https://launchpad.net/datacontroller
you can also visit our website and ask for more information via the download page or forum @ http://www.theacesolutions.com/
Thanks
|
|
|
|

|
Please do not commercialize any products here. If you follow the GNU license over your product refer instead to your own article rather then misleading people to download a shareware.
Best regards,
Niklas Henricson
Niklas Henricson
|
|
|
|

|
I tried to convert in MySQL7 but some table was not able to convert and displayed the following error message
Server: Msg 8114, Level 16, State 10, Line 1
Error converting data type DBTYPE_DBDATE to datetime.
|
|
|
|

|
I am sorry I'm not good in resolving or interpreting MySQL errors, please refer to their documentation.
Niklas Henricson
|
|
|
|

|
Hi there,
i tried that script yesterday to move data from mysql to mssql database. That worked fine using ur guide. But my database has about 50 different tables and i want to migrate all of them into the mssql database.
So is there a way to automatically copy the whole database / every table found in the source database and not table by table "by hand"?
Thx
|
|
|
|

|
It is possible to create a script that automates the migration, but it is part of database development to sometimes do it by trial and error, trying one by one table. That is the most common practice within database developers, before they generate a final script that will be ran in their production environment.
I'm sorry but I'm not aware of any automated solutions or products that would make this easier somehow.
Niklas Henricson
|
|
|
|

|
Very cool article. I was able to pull several databases into MSSQL using this technique. However, I have a log db that's about 25G and it just dies (runs out of memory) trying to import it wholesale. So I thought I'd use a where statement to break up the output. The only trouble is, after the first import it says the database object already exists. Well, yes, but why is that a problem? Is there a way to do this that would append to the database?
|
|
|
|

|
Google was my friend I should've checked there first, but here's the answer to my problem if anyone else runs into this:
INSERT INTO database.dbo.table
SELECT * FROM openquery(linked_server, 'SELECT * from db.table where DateColumn < "20071231" AND DateColumn >= "20071201"');
|
|
|
|

|
This is an excellent way to migrate a database. You have helped me enormously!
Thank you, thank you, thank you.
|
|
|
|

|
I'm happy the article helped you out!!
Niklas Henricson
|
|
|
|
|

|
Thank you! I'm glad the article helped you out!
Niklas Henricson
|
|
|
|

|
Niklas,
Thanks for the great article, I had to tweek it a bit as I'm accessing an MySQL database on an Ubuntu server but this gave me a solid base to work from.
Thanks,
Mike
"It doesn't matter how big a ranch ya' own, or how many cows ya' brand, the size of your funeral is still gonna depend on the weather." -Harry Truman.
Semper Fi
http://www.hq4thmarinescomm.com[ ^]
My Site
|
|
|
|

|
Thanks for the great 'how-to' this works perfectly as long as you follow the steps exactly as written. Saved me a lot of time and headaches.
|
|
|
|

|
Glad to be of assistance
Niklas Henricson
|
|
|
|

|
Hi,
I have followed your code but when I tried to get the data from mysql to SQL Server using this query
SELECT * INTO gbdbMS.dbo.shoutbox
FROM openquery(MYSQL, 'SELECT * FROM gbdb.shoutbox')
I got the following error message
Cannot initialize the data source object of OLE DB provider "MSDASQL" for linked server "MYSQL".
What could be the problem?
Thank you for your time and effort.
|
|
|
|

|
Hi,
I have managed to solve the problem by using more updated ODBC driver 5.1 instead of the 3.1 that I had before.
However, I am facing another problem, the data that I am importing from mysql is in Arabic character encoded in UTF8. When I used your query and imported this data into Sql Server, the data is displayed in a funny way that doesn't make any sense. I have changed the collation on the table and the column to Arabic but still no luck.
Any suggestion from your part about how to solve this problem? This is a business data and I cannot afford re-enter it.
Thank you for your time and effort
|
|
|
|

|
Your problem is generic for the Arabic characters. UTF8 encoding should support the migration. I have no clue but suggest you upgrade your mySQL database to higher version and then try with the migration from the beginning. Tell me if that works.
Best regards,
Niklas Henricson
|
|
|
|

|
Hi,
I am trying to create a linked server between MySQL and MS SQL Server so that the same database can be replicated at both the servers. I am initially testing the linked server with both the servers being on the localhost. Later i would migrate to different server locations.
I performed the instructions as mentioned. The creation of the linked server was easy. When i tried to copy one of the tables from MySQL to MS SQL Server, i am getting the following error.
OLE DB provider "MSDASQL" for linked server "MYSQL" returned message "[MySQL][ODBC 5.1 Driver]Lost connection to MySQL server at 'reading initial communication packet', system error: 0".
Msg 7303, Level 16, State 1, Line 1
Cannot initialize the data source object of OLE DB provider "MSDASQL" for linked server "MYSQL".
I am running this on an x64 machine with windows XP SP 2.
I have rechecked all the properties. Enabled OLE Automation in SQL Server 2005 Surface Area Configuration. Restarted the MySQL Server. Nothing has helped yet.
Kindly suggest what can be the issue and possible solution.
Thank You,
Soumen
|
|
|
|
|

|
Hi Niklas Henricson,
Thank you for getting back to my question. I tried what was mentioned in that bug report. Firstly i didn't find a bind-address value at
C:\Program Files\MySQL\MySQL Server 5.1\my.ini.
I used these 2 values for the bind-address under the section [mysqld]
bind-address=127.0.0.1
bind-address=localhost
I still am getting the following errors while trying to run a simple openquery...
SELECT * INTO dbName.dbo.tableName
FROM openquery(MYSQL, 'SELECT * FROM dbNameMySQL.tableNameMySQL')
------ERROR------
OLE DB provider "MSDASQL" for linked server "MYSQL" returned message "[MySQL][ODBC 5.1 Driver]Lost connection to MySQL server at 'reading initial communication packet', system error: 0".
Msg 7303, Level 16, State 1, Line 1
Cannot initialize the data source object of OLE DB provider "MSDASQL" for linked server "MYSQL".
------ERROR------
Also when i try to check the properties of the Linked server in MS SQL Server. Was basically trying to check if there are any issues while mapping the user login between the servers. Here are the following errors found...
------ERROR------
"The linked server has been updated but failed a connection test. Do you want to edit the linked server properties?"
------ERROR------
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.Express.ConnectionInfo)
------ERROR------
Cannot initialize the data source object of OLE DB provider "MSDASQL" for linked server "MYSQL".
OLE DB provider "MSDASQL" for linked server "MYSQL" returned message "[MySQL][ODBC 5.1 Driver]Lost connection to MySQL server at 'reading initial communication packet', system error: 0". (.Net SqlClient Data Provider)
------ERROR------
Would re-installing or changing certain passed in values in MySQL help? Kindly suggest what can be a work around.
Thank You
Soumen
|
|
|
|

|
Hi Niklas Henricson,
I wanted to update the status of creating the linked server. I was able to successfully configure a MS SQL Server and MySQL server linked server connection on a different 32 bit machine. Both the servers are local and i tried the same steps that you had mentioned. Its strange though that the linked server was giving me problems on my x64 machine on which i was trying till now. Any idea why that would happen?
Thank You,
Soumen
|
|
|
|

|
Hello Soumen,
The only thing I can think of is "myODBC connector" version you are using is the 32 bit one. Are you sure you did a download on the 64 bit one?
The download webpage is located at: http://dev.mysql.com/downloads/connector/odbc/5.1.html#winx64[^]
If that is not your issue and have verified the version of your "myODBC connector", I have nothing else to think of. For that I am very sorry!
My suggestion then is to complete the migration at your 32-bit enviroment and then finally restore the database at your x64 platform.
Best regards,
Niklas Henricson
|
|
|
|

|
Hi Niklas,
I have the 64-bit version of the myODBC connector. I was myself surprised with this kind of behavior. Anyways i would do as you suggested. Use migration on the 32-bit environment and then restore on 64-bit.
Thank You,
Soumen
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
|
Migrate MySQL to Microsoft SQL Server in just a few simple steps
| Type | Article |
| Licence | CPOL |
| First Posted | 5 Sep 2008 |
| Views | 225,208 |
| Bookmarked | 53 times |
|
|