我正在尝试使用带有链接服务器的 OPENQUERY 将数据从 SQL Server 导入 mysql。
我已经导入了几个表,但是我遇到了一个包含长 varchar 字段的表的问题。
每次我运行此查询时,我都会得到以下信息
Msg 7344, Level 16, State 1, Line 2
The OLE DB provider "MSDASQL" for linked server "Serv1" could not INSERT INTO table "[MSDASQL]" because of column "Notes". Could not convert the data value due to reasons other than sign mismatch or overflow.
Notes 列在 SQL servr 中属于 varchar(8000) 类型,在 MySQL 中也是 varchar(8000) 类型。
问题是什么?为什么它给我这个错误?不是我试图先将注释写成 varchar(8000) 但这没有用。
INSERT OPENQUERY (Serv1, 'SELECT
id,
i3_identity,
mid,
Notes,
Comments,
result_code,
Disposition,
completed_on,
calltype
FROM finaltesting.activities')
SELECT
CAST(ID AS int) AS id,
CAST(identity AS int) AS identity,
CAST(merchantAccount AS varchar(255)) AS mid,
Notes,
CAST(Comments AS varchar(8000)) AS Comments,
CAST(FinishCode AS varchar(255)) AS result_code,
CAST(Disposition AS varchar(255)) AS Disposition,
CAST(callDate AS datetime) AS completed_on,
CAST(CallType AS varchar(255)) AS calltype
FROM activities
由于符号不匹配或溢出以外的原因,无法转换数据值。