I\'m trying to migrate a table from MySql to MSSQL using openquery
but I keep getting the following error message:
OLE DB provider \"MSDASQL\" for l
I managed to fix this issue by changing the datatype to TEXT
at both MySql and MSSQL side.
In my testing, I found that adding CAST(field as char(4000))
also solved the problem.
I created the following in a MySQL 5.1 database:
create table tmp_patrick (summary_text varchar(4096));
insert into tmp_patrick values ('foo');
When I executed the following on SQL Server 2008 R2 SP1 (10.50.2500), using MySQL ODBC driver 64-bit, either version 5.1 or 5.2w:
select * from openquery(MYSQL, 'select summary_text from scratch.tmp_patrick')
it generates the error:
OLE DB provider "MSDASQL" for linked server "MYSQL" returned message "Requested conversion is not supported.".
Msg 7341, Level 16, State 2, Line 1
Cannot get the current row value of column "[MSDASQL].summary_text" from OLE DB provider "MSDASQL" for linked server "MYSQL".
but if I add CAST
:
select * from openquery(MYSQL, 'select CAST(summary_text as char(4000)) from scratch.tmp_patrick')
then it works. Casting to char(4001) will fail.
It's not clear to me where the 4000 character limit comes from.