Should I use OpenQuery to query a MySQL related server with SQL Server?

I am querying a MySQL related server from SQL Server.

I can query the linked server using OpenQuery, as in the following example.

SELECT * FROM OPENQUERY(MyLinkedServer, 'SELECT * FROM SomeTable') 

I tried to query the linked server using a four-part name, as in the following example.

 SELECT * FROM MyLinkedServer.MyDatabase.DBO.SomeTable 

This returns an error stating that "the provider does not provide the necessary interfaces for using the directory or schema."

Is there a way to query a linked server without using OpenQuery?

Thanks!

Update: to the answer "Schroeder" the correct syntax is as follows.

 SELECT * FROM MyLinkedServer...SomeTable 
+4
source share
1 answer

Maybe, but MS recommends using openquery:

This method allows SQL Server to send a command to a directly related OLAP without trying to parse it.

You can find examples here in the section โ€œRelated Examples of Four-Name Serversโ€

In addition, I found this :

If you receive these error messages, the table may not be on [Linked DB] or you may not have rights to this table.

I would make sure your mysql db granted permissions to your sql server.

0
source

Source: https://habr.com/ru/post/1381948/


All Articles