Inserting row from MSSQL to MySQL - mysql

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?

Related

Update problem via OLE DB provider MSDASQL - Linked Server

i am trying to update table via OLE DB provider MSDASQL for a linked server.
Connection is working, select statments work without problems. Update also worked until now.
Linked Server: MYSQL DB - update via MYSQL workbench works fine
But now i get the following error:
The OLE DB provider "MSDASQL" for linked server "xxx" could not UPDATE
table "[xxx]...[yyy.zzz]". [SQLSTATE 42000] (Error 7343) OLE DB
provider "MSDASQL" for linked server "xxx" returned message
"[MySQL][ODBC 8.0(w) Driver][mysqld-5.7.38-google-log]You have an
error in your SQL syntax; check the manual that corresponds to your
MySQL server version for the right syntax to use near '.zzz SET
trn_state=? WHERE check=? AND check_pos=? AND checkopen_time=' at line
1". [SQLSTATE 01000] (Error 7412). The step failed.
My update statement:
update [xxx]...[yyy.zzz]
set trn_state = 1
where trn_state = 0
And yes, it is the first line of the statement - i don't know why the error is referencing things that are not in the statement.
Error message does not match my statement - why ?
Whats the reason ? What am I doing wrong ?
Error in provider options or linked server properties ? Can it be a wrong setting on the other side ?

How to connect from MSSQL server running on ubuntu to MySQL?

I'm trying to connect to a MySQL server instance, using a distributed query, with the folling query:
SELECT *
FROM openrowset('SQLNCLI11','server=<>,33333;uid=root;pwd=<>','SELECT * FROM mov.users')
I get the following errors:
OLE DB provider "SQLNCLI11" for linked server "(null)" returned message "Client unable to establish connection due to prelogin failure".
OLE DB provider "SQLNCLI11" for linked server "(null)" returned message "Protocol error in TDS stream".
Msg 7303, Level 16, State 1, Line 1
Cannot initialize the data source object of OLE DB provider "SQLNCLI11" for linked server "(null)".
I've tried using SSL on my MSSQL instances and nothing. I've ran the execute command for the sp_configure to enable 'ad hoc distributed queries', and nothing. I've tried to create a linked server but it doesn't seem to be a mssql on linux compatible feature.
How can I cestablish a direct connection between a MSSQL running on linux to a MySQL server?
On Linux, SQL Server does not support Linked Servers to data sources other than SQL Server. See unsupported features

MS SQL Server and MySQL through Linked Server

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.

Update MySQl Linked server from sql server trigger

Error I get when I run
OLE DB provider "MSDASQL" for linked server "WEBSTAGING" returned
message "[MySQL][ODBC 5.3(w) Driver]Optional feature not supported".
Msg 7391, Level 16, State 2, Procedure
trg_DeliveryPartMap_Mysql_Stockupdate, Line 32 The operation could not
be performed because OLE DB provider "MSDASQL" for linked server
"WEBSTAGING" was unable to begin a distributed transaction.
moreover select Query works fine in sql server trigger.
But when I run on Linnked server it works fine
UPDATE OpenQuery(WEBSTAGING, 'SELECT inventory, id, originalId FROM product
WHERE originalId=Xxx') SET inventory = 13
I solved it by calling stored procedure from local server of Linked Server (MySQL Server)
without using OpenQuery I used Exec (Linked server stored procedure)
and it worked
Thanks

Intermittent OLE DB error from MSDASQL for OPENQUERY call to MySql

I have a SQL statement running in SQL Server 2012 that sometimes works fine (returns a little over 4,000 rows in about 25 seconds) and sometimes fails after about 9 1/2 minutes with the error:
The OLE DB provider "MSDASQL" for linked server "Helpdesk" indicates
that either the object has no columns or the current user does not
have permissions on that object.
Here is the statement:
SELECT *
FROM OpenQuery(Helpdesk,
'SELECT ticketpostid,ticketid,dateline,userid,fullname,subject,editeddateline,contents,responsetime,staffid
FROM swticketposts
WHERE ticketpostid > 6609667'
)
Helpdesk is a Linked SQL that connects to a remotely located MySQL 5.5 server via an ODBC System DSN.
What are the possible causes of getting this error intermittently?