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 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].description" from OLE DB provider "MSDASQL" for linked server "MYSQL".
The SQL query I'm trying to run:
insert into dbo.tickets (id, description, createdAt)
select * from openquery(MYSQL, 'select * from mydb.tickets')
With openquery I have already copied a couple tables but this one tricks me.
On both side of databases the description field is varchar(8000). In MySql there is no row where description is null and the longest description is only 5031 characters.
I tried creating a new view in MySql with the same data structure but got the same error.
I can't determine which row has an invalid description field because the table contains more than 65000 rows.
I also tried dumping the data into an SQL file but I got OutOfMemoryException in Management Studio. The dumped sql file itself is about 60 MB.
Any suggestions or other ways of migrating this data?
Thanks in advance!
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.
I managed to fix this issue by changing the datatype to TEXT at both MySql and MSSQL side.
Related
We have MS SQL Server 2012 and MySQL 5.5, and we need to sync one table data between the two databases. So that whenever a record is inserted in the table "trainee" in MS SQL Server then it should directly copied to the table "trainee" in MySQL database.
We used the linked server, and it works fine for reading data from MySQL with the following driver:
MySQL ODBC 5.2 UNICODE Driver
And then we added a Trigger on the table in MS SQL Server with the following code:
USE [case]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER TRIGGER [dbo].[Inserttms]
ON [case].[dbo].[mdl_tms_trainee]
AFTER INSERT
AS
Insert into dbo.tms (id,u_id,trainee_number) Values ('8','8','888');
Further more, we enable the DTC in the server, set True for RPC and RPC OUT in the LInked Server, and even created aview in the local database in MS SQL Server in order to use workaround, but these all never solve the below problem.
OLE DB provider "MSDASQL" for linked server "TMSCASEU" returned message "[MySQL][ODBC 5.2(w)
Driver]Optional feature not supported".
Msg 7391, Level 16, State 2, Procedure Inserttms, Line 5
The operation could not be performed because OLE DB provider "MSDASQL" for linked server
"TMSCASEU" was unable to begin a distributed transaction.
I am connected to a linked MySQL-server with SQL Server 2016. When I run the following query:
select * from openquery([servername], 'select * from database.tableName')
I get the error:
Msg 7399, Level 16, State 1, Line 6 The OLE DB provider "MSDASQL" for
linked server "servername" reported an error. The provider reported an
unexpected catastrophic failure. Msg 7330, Level 16, State 2, Line 6
Cannot fetch a row from OLE DB provider "MSDASQL" for linked server
"servername".
The strange thing is that it works perfectly on three of the six tables in the database. There is no schema, and the table names are written correctly. Plees help :)
You could try changing your SQL to this instead:
exec('SELECT * FROM database.tablename') at [servername]
I encountered this issue when querying an AS400 from MSSQL - the above resolved my issue.
I have a mysql database that I need to be imported into sql server via a linked server. Two of the mysql columns are blob and mediumblob. The columns in mssql are varbinary(max). When I execute a query at the linked server, I get the error:
OLE DB provider "STREAM" for linked server "(null)" returned message "Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.".
Msg 0, Level 11, State 0, Line 19
A severe error occurred on the current command. The results, if any, should be discarded.
The error goes away when I exclude the blob and medium blob columns from the select statement. Is there a conversion or workaround for this?
I have set up a linked server with the MSDASQL provider in MSSQL to connect to a MySQL instance. I have installed and configured the MySQL ODBC 5.1 Driver connector. Everything seems to work fine to query data from the MySQL instance, but inserting or updating any data is not working. The following command:
INSERT OPENQUERY(MYSQL, 'SELECT id FROM test')
values (1)
intended on inserting a simple value of 1 returns the error:
OLE DB provider "MSDASQL" for linked server "MYSQL" returned message "[MySQL][ODBC 5.1 Driver][mysqld-5.5.21]Commands out of sync; you can't run this command now".
Msg 7343, Level 16, State 2, Line 1 The OLE DB provider "MSDASQL" for linked server "MYSQL" could not INSERT INTO table "[MSDASQL]".
I have also attempted to open an editable results pane for the MySql test table and insert data that way, I receive the following error:
The operation could not be performed because OLE DB provider "MSDASQL" for linked server "MYSQL" was unable to begin a distributed transaction.
OLE DB provider "MSDASQL" for linked server "MYSQL" returned message "[MySQL][ODBC 5.1 Driver]Optional feature not supported".
Does anyone have some insight or experience on how to solve this problem?
Running MSSQL Server 2008 Standard SP 2 64-bit on Win2K8. I have installed on this server the 64-bit MySQL ODBC driver version 5.1.8 from 10/28/2010. I have configured a DSN linking to a MySQL server 5.1 running on a Mac apple-darwin9.8.0 server (don't ask me, I inherited this). I have successfully created a linked server via MDSASQL to a specific MySQL database.
From the SQL Server box I can run simple queries of the nature
SELECT * FROM mysql_table WHERE id = 1;
However, it is painfully slow. A query as above takes 19 minutes and 52 seconds to execute; the same query takes 0.04 seconds when executed locally.
Further, I attempted to execute a simple update of the nature
UPDATE mysql_table SET field = 0 WHERE id = 1;
This ran for 2 hours before returning the following error:
OLE DB provider "MSDASQL" for linked server "LINKED_MYSQL" returned message "Out of memory.".
Msg 7399, Level 16, State 1, Line 3
The OLE DB provider "MSDASQL" for linked server "LINKED_MYSQL" reported an error. The provider ran out of memory.
Msg 7330, Level 16, State 2, Line 3
Cannot fetch a row from OLE DB provider "MSDASQL" for linked server "LINKED_MYSQL".
This comes on the heels of several failed jobs involving updates to the same table, all of which fail approximately two hours after they commence.
I have checked the permissions on the mysql and the user specified in the DSN has the appropriate permissions (well, all permissions) in mysql.user.
I would be most appreciative if anyone could give me any avenues to investigate to get this working.
Avoid joins to linked server tables and have a look at dynamic openqueries
And refer to this question that posted ealier.
Linked Server Performance and options