Microsoft SQL链接MySQL服务器 - 无法从PHP查询

时间:2011-12-09 23:02:28

标签: php mysql sql-server

我在Microsoft SQL Server上设置了链接的MySQL服务器。我可以在MSSQL Management Studio中成功运行此查询...

SELECT * FROM OPENQUERY(MYSQL, 'SELECT * FROM countries')

当我从PHP网站运行时,我收到此错误...

Message: Failed to query SQL statement. Reason: Heterogeneous queries require the ANSI_NULLS and ANSI_WARNINGS options to be set for the connection. This ensures consistent query semantics. Enable these options and then reissue your query.

我有什么想法可以让它发挥作用?

1 个答案:

答案 0 :(得分:2)

解决方法是在链接服务器调用下方移动“SET ANSI_WARNINGS OFF”语句。为了更安全,在sp / query的末尾应用“SET ANSI_WARNINGS ON”语句。

<强>更新

SET ANSI_WARNINGS ON

SET ANSI_NULLS ON

SELECT * FROM OPENQUERY(MYSQL, 'SELECT * FROM countries')

http://social.msdn.microsoft.com/Forums/en-US/sqldataaccess/thread/1d501b57-fc58-4fbe-9bec-6c38ad158a62