SSIS Package – Error Exporting Data to Flat File – Invalid Character

ssis

I have an SSIS package where I pull data from a 3rd party source into a CSV file.

I get this error:

"Data conversion failed. The data conversion for column "Description" returned status value 4 and status text "Text was truncated or one or more characters had no match in the target code page.".

Cannot copy or convert flat file data for column "Description".

SSIS Error Code DTS_E_PROCESSINPUTFAILED. The ProcessInput method on component "Flat File Destination" (20300) failed with error code 0xC02020A0 while processing input "Flat File Destination Input" (20304). 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."

There seems to be an invalid character causing this issue…

enter image description here

I tried to remove it using this code but still an issue…

enter image description here

Best Answer

You have to deal with the unicode replacement character by calling it what it is:

Row.Description = Row.Description.Replace(NCHAR(65533), "a")

EDIT:

I apologize as I first gave you a pseudo-SQL Server solution, but with some additional research learned that SSIS behaves a little differently. I'm linking my source that gives multiple solutions, and for an answer will include the first. It seems that you could add a derived column component that would allow you to add a new column (e.g. strDescription from your table using the Type Cast operator DT_STR which will convert the unicode to string. You should then be able to use this derived column in place of the original column in you CSV destination. source Hope that helps!