简体   繁体   中英

Migrate utf-8 data from mysql to SQL Server 2005

I have a live MySQL database with UTF-8 data in it. I'm trying to migrate it to SQL Server 2005.

All table fields and all data are in UTF8.

The destination database will have SQL_Latin1_General_CP1_CI_AS collation . What I did so far was to create an ODBC connection to my MySQL database and do the following:

EXEC master.dbo.sp_addlinkedserver @server = N'MYSQL2', @srvproduct=N'MySQL', @provider=N'MSDASQL', @provstr=N'DRIVER={MySQL ODBC 5.1 Driver}; SERVER=SERVERHOST; DATABASE=mysqldb; USER=mysqluser;PASSWORD=PASSWORD; OPTION=3;charset:utf8;';

select * into mssql.dbo.members from openquery(MySQL, 'select * from mysqldb.members');

the collation that my SQL Server has is Greek_CI_AS.

the destination database has SQL_Latin1_General_CP1_CI_AS collation and I created another one with Greek_CI_AS collation just to see if that was the problem.

The import went well and all table fields in SQL Server were created correctly BUT the data that was stored had encoding ISO-8859-7 (which i presume comes from the Greek_CI_AS collation).

this is a problem since our current site has UTF-8 pages and it should stay that way.

If i use Firefox and MDDB2 to try and get the data I get confused characters. If I change the View-> encoding to ISO-8859-7 I see the data correctly .. but this is not the solution

so how to do this migration and have the correct encoding on the destination SQL Server?

any help appreciated thanks

you need to tell us what types of data you're using on the MS SQL side.

Are you using VARCHAR or NVARCHAR?

You need to use NVARCHAR if you want to store unicode data.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM