2013-08-05 67 views
0

我想使用OPENQUERY與鏈接的服務器將數據從SQL Server導入到mysql。SQL Server無法轉換數據值

我已經導入了幾個表,但我有一個長表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. 

列說明是在MySQL SQL servr也VARCHAR(8000)的類型爲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 

由於符號不匹配或溢出以外的原因,無法轉換數據值。

+0

也許這很愚蠢,但你有沒有試過'從那個'選擇''Creeate table'? SQL Server端或MySQL中的 – jaczes

+0

? – Jaylen

回答

0

我能夠通過將MySQL中的列類型從varchar(8000)更改爲Text來解決此問題。我正在使用MySQL 5.6.12。將表單SQL Server轉換爲MySQL服務器時可能會出現列類型問題。

謝謝