我正在尝试使用 SQL 服务器 OPENQUERY 函数从 Mysql 服务器中提取数据。当我运行查询来计算 w mysql 服务器中的记录时,我得到的值没问题
-this query works and it return the total records found
SELECT count(*) AS total FROM OPENQUERY(LinkedServer, 'SELECT * FROM mydb_name.users')
但是当我这样做时
SELECT login_user FROM OPENQUERY(LinkedServer, 'SELECT * FROM mydb_name.users')
我收到这个错误
Msg 7347, Level 16, State 1, Line 1
OLE DB provider 'MSDASQL' for linked server 'LinkedServer' returned data that does not match expected data length for column '[MSDASQL].login_user'. The (maximum) expected data length is 60, while the returned data length is 16.
我试过但没用
SELECT CONVERT(CHAR(60), login_user) AS name FROM OPENQUERY(LASWEB, 'SELECT * FROM mydb_name.users')
我假设这是一个数据类型问题,但我该如何解决呢?如何提取我需要的数据?
谢谢