SQLTeam.com | Weblogs | Forums

Getting error when loading null values in ssis

Hi I have one doubt in ssis
how to load null vaules in inter datattype filed
i want load csv file data into sql server table using ssis package.

soruce csv filedata is :emp
id | Name | deptno
1 |ab |NULL
2 | |NULL
3 |dhd |NULL

Targeet sql server table emp:

id --int ,name varchar(50),deptno int

I treid datatype using showadvaned mode for external columns and output columns as per target table datatypes

after that I execute the package .here i am unable to load null values in int deptno filed

and getting errors like below :

[OLE DB Destination [27]] 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 [27]] Error: There was an error with OLE DB Destination.Inputs[OLE DB Destination Input].Columns[depno] on OLE DB Destination.Inputs[OLE DB Destination Input]. The column status returned was: "The value could not be converted because of a potential loss of data.".

[OLE DB Destination [27]] Error: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR. The "OLE DB Destination.Inputs[OLE DB Destination Input]" failed because error code 0xC0209077 occurred, and the error row disposition on "OLE DB Destination.Inputs[OLE DB Destination Input]" specifies failure on error. An error occurred on the specified object of the specified component. There may be error messages posted before this with more information about the failure.

[SSIS.Pipeline] Error: SSIS Error Code DTS_E_PROCESSINPUTFAILED. The ProcessInput method on component "OLE DB Destination" (27) failed with error code 0xC0209029 while processing input "OLE DB Destination Input" (40). The identified component returned an error from the ProcessInput method. The error is specific to the component, but the error is fatal and will cause the Data Flow task to stop running. There may be error messages posted before this with more information about the
failure.
i tried another way using derived column : UPPER([deptno]) == "NULL" ? NULL(DT_I4) : [deptno] this also giving error

can you please tell me how to load null values in sql server tables for integer datatypes using ssis packages

Flat files don't know what null is, so it's reading it like a string

First - on the flat file source you need to check the box to retain null values:

image

Second - you need to validate the actual values in the file. If those values are actually the word NULL - then you need to setup the connection manager to read the values as a string and then use a data conversion task to convert from the string to the numeric value.

Hopefully - the file does not contain a string NULL value. If it does - I would recommend working with the sender to have those removed so you can set the connection manager to read that field directly as a numeric value.