Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SELECT * FROM Linked MySQL server

I have a SQL Server 2012.(120.120.55.15)

Today I linked MySQL server(120.120.55.30) to my SQLServer and gave it a name "MYSQL".

In Object Explorer everything seems fine. I can see MySQL server's database "exampleDataBase" and tables in it.

But when I try to run select query like this:

SELECT * 
FROM   openquery
        (
        MYSQL, 
        '
         SELECT * 
         FROM [exampleDataBase].[msProcMatrix]
        '
        )

I get a mistake:

Msg 7399, Level 16, State 1, Line 1 The OLE DB provider "MSDASQL" for linked server "MYSQL" reported an error. The provider did not give any information about the error. Msg 7350, Level 16, State 2, Line 1 Cannot get the column information from OLE DB provider "MSDASQL" for linked server "MYSQL".

What should be additionally done to use my linked MySQL server?

like image 308
Almazini Avatar asked Mar 11 '26 16:03

Almazini


2 Answers

Found the decision:

SELECT * 
FROM openquery(MYSQL, 'SELECT * FROM exampleDataBase.msProcMatrix')

Without brackets!

Strange for me but works...

like image 178
Almazini Avatar answered Mar 14 '26 05:03

Almazini


This worked great for me after fighting the same issue on MS SQL Server 2008 64bit using the MY SQL 3.51 64 bit ODBC driver

SELECT *
FROM OPENQUERY
(
   linked_server_name,
   'SELECT * FROM linked_database_name.linked_table_name'
)
like image 27
user2891719 Avatar answered Mar 14 '26 06:03

user2891719



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!