Friday, February 27, 2015

SSIS error: [Flat File Destination [187]] Error: Data conversion failed. The data conversion for column "col1" returned status value 4 and status text.

If you have worked on SSIS tool, at some point while working in Dataflow task we will face this issue.
Error statement : "[Flat File Destination [187]] Error: Data conversion failed. The data conversion for column "col2" returned status value 4 and status text "Text was truncated or one or more characters had no match in the target code page."

This usually happens when we are loading data from database source to flat file destination or if loading from flat file source to database destination.
I assume it occurs more often when it is database source to flat file destination.

Here are the few steps to troubleshoot this issue. I usually follow the same order.

  • Run the query in SSMS and see if you are seeing some dirty data. Usually this happens when we pull data from different platform like Mac or Linux. Example the file path.
  • Right click on flat file destination, click on Show advance editor and go to Input and output column tab. On external columns see if the data type and length of the col2 (here in example) is as per request. Should be wide enough . Match the same with input columns.
Once you are sure the data types are matching, go to next step.
  • Double click on the destination file connection in connection manager and make sure if you have checked unicode option or not. If you are using nvarchar or DT_WSTR as datatpe then I would suggest to check this option.
I have used above steps most of the times and it has worked for me.

Let me know if you are aware of any other trouble shooting methods in SSIS for the above mentioned error.