In this tutorial, I will show how to handle a NULL value loaded by SSIS from a CSV file. Note that some knowledge of Excel, SQL and programming is necessary.

1.  Build a CSV file. Here’s a sample file:

Sample CSV File

2.  Create a table in the SQL server database:

create table employee


       employeeid varchar(10) not null,

       name varchar(100) not null,

       hiredate datetime not null,

       terminatedate datetime null,

       job varchar(100) null,

       seq int IDENTITY(1,1) NOT NULL


create unique clustered index PK on employee (seq)

3.  Start SSIS and create a new package. My example is ImportCSV.dtsx

4.  Build the SSIS package and run the package:

SQL SSIS Package

5.  After running the package, you can see the Execution Results shows the following errors even though we have set the terminatedate field to be a NULL value:

Visual studio SSIS results

[OLE DB Destination [31]] Error: SSIS Error Code DTS_E_OLEDBERROR.  An OLE DB error has occurred. Error code: 0x80004005.

An OLE DB record is available.  Source: “Microsoft SQL Server Native Client 11.0”  Hresult: 0x80004005  Description: “Invalid character value for cast specification”.

[OLE DB Destination [31]] Error: There was an error with OLE DB Destination.Inputs[OLE DB Destination Input].Columns[terminatedate] 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 [31]] 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” (31) failed with error code 0xC0209029 while processing input “OLE DB Destination Input” (44). 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.

6.  The solution is to add a script component. Open the script component and enable all the fields on the Input Columns:
script transformation editor

7.  Then Inputs and Outputs, add a field in the Output and set the DataType to string:
script transformation editor outputs

8.  Modify the script and the code to the Input0_ProcessInputRow method:

if (string.IsNullOrEmpty(Row.terminatedate) || Row.terminatedate_IsNull)

Row.TerminateValue = “01/01/1900”;


Row.TerminateValue = Row.terminatedate.ToString();

execute script in visual studio

9.  Put the link together with the Flat File Source to Script Component and to OLE DB Destination. Then go back to the OLE DB Destination and remap terminatedate to TerminateValue:

data flow SSIS

OLE DB destination editor

10.  Run it and you should see no errors this time:

import CSV data flow review

11.  Look in the SQL server database backend and you can see that the terminate field contains the default value:

review results in SQL

Note this solution can also be applied to other file types besides CSV. As always, please contact the specialists at MIBAR with any questions or for additional support.