简体   繁体   中英

SSIS: Unable to cast object of type 'System.Decimal' to type 'System.Char[]'

I am doing data integration from SQL Server 2008 R2 to PostgreSQL 9.5.

I have table with following details:

Table : In SQL Server

create table test
(
    cola int,
    colb numeric(18,0),
    colc varchar(50),
    cold datetime,
    cole bit,
    colf char(1)
);

Table : In PostgreSQL

create table test
(
    cola int,
    colb numeric(18,0),
    colc varchar(50),
    cold timestamp(0),
    cole boolean,
    colf char(1)
);

Package details:

Source : OLE DB Source (SQL Server)

Data Conversion : On column colc to DT_WSTR

Destination : ADO NET Destination (PostgreSQL)

Error Details:

[ADO NET Destination [129]] Error: An exception has occurred during data insertion, the message returned from the provider is: Unable to cast object of type 'System.Decimal' to type 'System.Char[]'.

Data Conversion: 在此处输入图片说明

Mapping: 在此处输入图片说明

Sample Data: In SQL Server

insert into test1 values(1,NULL,'z','2017-02-12 12:21:50.000',1,'C');
insert into test1 values(2,1344,'Xuz','2017-02-12 12:21:50.000',0,'D');
insert into test1 values(3,NULL,'T','2017-02-12 12:21:50.000',1,'E');

Error: 在此处输入图片说明

Input and Output properties :

在此处输入图片说明

在此处输入图片说明

Your column mapping looks fine, you have to check your columns data type using the advanced editor.

Right click on Ado.net Destination --> Input and Output Columns Tab --> check that columns data type are defined correctly.

Side Note: Why converting colb if it is a numeric column

The following data conversion works fine to me.

Data Conversion : I have converted colb from NUMERIC to CHAR in the data conversion part and works fine to me.

colb string[DT_STR]

在此处输入图片说明

This conversion looks very strange to me but its working fine that's matter.

Let me know if I am wrong here.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM