SELECT * FROM 链接的 MySQL 服务器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16687999/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
SELECT * FROM Linked MySQL server
提问by Almazini
I have a SQL Server 2012.(120.120.55.15)
我有一个 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".
今天我将 MySQL 服务器(120.120.55.30)链接到我的 SQLServer 并给它一个名称“MYSQL”。
In Object Explorer everything seems fine. I can see MySQLserver's database "exampleDataBase" and tables in it.
在对象资源管理器中,一切似乎都很好。我可以看到MySQL服务器的数据库“ exampleDataBase”和其中的表。
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".
消息 7399,级别 16,状态 1,第 1 行链接服务器“MYSQL”的 OLE DB 提供程序“MSDASQL”报告错误。提供者没有提供有关错误的任何信息。消息 7350,级别 16,状态 2,第 1 行无法从链接服务器“MYSQL”的 OLE DB 提供程序“MSDASQL”获取列信息。
What should be additionally done to use my linked MySQL server?
使用我链接的 MySQL 服务器还需要做什么?
回答by Almazini
Found the decision:
发现决定:
SELECT *
FROM openquery(MYSQL, 'SELECT * FROM exampleDataBase.msProcMatrix')
Without brackets!
不带括号!
Strange for me but works...
对我来说很奇怪但有效...
回答by user2891719
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
在使用 MY SQL 3.51 64 位 ODBC 驱动程序在 MS SQL Server 2008 64 位上解决了同样的问题后,这对我很有用
SELECT *
FROM OPENQUERY
(
linked_server_name,
'SELECT * FROM linked_database_name.linked_table_name'
)
回答by Marius
You might need a schema name between the database name and the table name.
您可能需要数据库名称和表名称之间的模式名称。
SELECT *
FROM openquery
(
MYSQL,
'
SELECT *
FROM [exampleDataBase].**[dbo]**.[msProcMatrix]
'
)
回答by Roberto Vargas
When I working with linked server, I never use Select * From
.
当我使用链接服务器时,我从不使用Select * From
.
Try with Select Column1, Column2, ... ColumnN From
.
尝试使用Select Column1, Column2, ... ColumnN From
.
Always works fine for me.
对我来说总是很好。
回答by Vadim Rapp
If the default catalog ("exampleDataBase") is configured in ODBC, the following will work as well:
如果在 ODBC 中配置了默认目录(“exampleDataBase”),以下内容也将起作用:
select * from MYSQL...msProcMatrix
select * from MYSQL...msProcMatrix
回答by Parassharma1990
You Can try this query .
你可以试试这个查询。
EXEC ( 'SELECT * FROM [exampleDataBase].[msProcMatrix]' ) AT MYSQL
EXEC ('SELECT * FROM [exampleDataBase].[msProcMatrix]') 在 MYSQL
回答by vahid basirat
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.
在名称中包含额外的级别可能会解决您的问题。