我是否必须使用OpenQuery从SQL Server查询MySQL链接服务器? [英] Do I have to use OpenQuery to query a MySQL Linked Server from SQL Server?

查看:515
本文介绍了我是否必须使用OpenQuery从SQL Server查询MySQL链接服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从SQL Server查询MySQL链接服务器.

I'm querying a MySQL linked server from SQL Server.

我可以使用OpenQuery查询链接的服务器,如下例所示.

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

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

我已尝试使用四部分名称查询链接服务器,如以下示例所示.

I have tried querying the linked server using a four-part name as in the following example.

SELECT * FROM MyLinkedServer.MyDatabase.DBO.SomeTable

返回错误,指出提供者未公开使用目录或架构的必要接口."

That returns an error stating that "the provider does not expose the necessary interfaces to use a catalog or schema."

是否有任何方法可以在不使用OpenQuery的情况下查询链接服务器?

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

谢谢!

更新:根据Shredder的回答,正确的语法如下.

SELECT * FROM MyLinkedServer...SomeTable

推荐答案

可能,但是MS建议您使用openquery:

It is possible, but MS recommends that you use the openquery:

此方法允许SQL Server将命令直接发送到链接的 OLAP提供程序,而无需尝试对其进行解析.

This method lets SQL Server send the command directly to the linked OLAP provider, without trying to parse it.

您可以在由四部分组成的链接服务器示例"下的此处中查看示例名称"

You can have a look at the examples here under "Linked server examples with four-part names"

此外,我发现了:

Also, I found this:

如果收到这些错误消息,则表中可能缺少表 [Linked DB]模式,否则您可能对该表没有权限.

If you receive these error messages, a table may be missing in the [Linked DB] schema or you may not have permissions on that table.

我将验证您的mysql数据库是否具有对sql服务器的访问权限.

I would verify that your mysql db has given access rights to your sql server.

这篇关于我是否必须使用OpenQuery从SQL Server查询MySQL链接服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆