2015年6月22日 星期一

[SSIS][PostgreSQL]Error code:0x80040E21 Description: Multiple-step OLE DB operation generated errors.

        在SSIS Project裡,我打算從PostgreSQL匯入資料到SQL Server上,然後執行時出現如下錯誤,從錯誤訊息裡得知好像是欄位型態轉換的問題

[OLE DB Destination [29]] Error: SSIS Error Code DTS_E_OLEDBERROR.  An OLE DB error has occurred. Error code: 0x80040E21.
An OLE DB record is available.  Source: "Microsoft SQL Server Native Client 11.0"  Hresult: 0x80040E21
Description: "Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.".

[OLE DB Destination [29]] Error: An error occurred while setting up a binding for the "name" column. The binding status was "DT_NTEXT".
The data flow column type is "DBBINDSTATUS_UNSUPPORTEDCONVERSION".
The conversion from the OLE DB type of "DBTYPE_IUNKNOWN" to the destination column type of "DBTYPE_WVARCHAR" might not be supported by this provider.

        PostgreSQL該欄位上是TEXT,而SQL端對應欄位是NVARCHAR,我中間沒有加入資料轉換元件,對於異質資料轉換,我習慣在來源端就先轉掉好了,比較不容易出問題,所以直接在PostgreSQL來源端用cast轉換就好,例子如下
select id,cast(name as varchar(32)) as name from accounts
         這樣就沒再出錯囉

0 意見:

張貼留言