3

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?

Your Common Sense
  • 156,878
  • 40
  • 214
  • 345
Almazini
  • 1,825
  • 4
  • 25
  • 48

7 Answers7

16

Found the decision:

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

Without brackets!

Strange for me but works...

veljasije
  • 6,722
  • 12
  • 48
  • 79
Almazini
  • 1,825
  • 4
  • 25
  • 48
4

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'
)
Jon Lin
  • 142,182
  • 29
  • 220
  • 220
1

You might need a schema name between the database name and the table name.

SELECT * 
FROM   openquery
        (
        MYSQL, 
        '
         SELECT * 
         FROM [exampleDataBase].**[dbo]**.[msProcMatrix]
        '
        )
veljasije
  • 6,722
  • 12
  • 48
  • 79
Marius
  • 23
  • 5
1

When I working with linked server, I never use Select * From.

Try with Select Column1, Column2, ... ColumnN From.

Always works fine for me.

veducm
  • 5,933
  • 2
  • 34
  • 40
0

If the default catalog ("exampleDataBase") is configured in ODBC, the following will work as well:

select * from MYSQL...msProcMatrix

Vadim Rapp
  • 33
  • 5
-2

You Can try this query .

EXEC ( 'SELECT * FROM [exampleDataBase].[msProcMatrix]' ) AT MYSQL

-2

Please try the statement in the format below .. for me it works very well

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

Including the extra levels in the name may solve your issue.

Turophile
  • 3,367
  • 1
  • 13
  • 21
vahid basirat
  • 445
  • 5
  • 7