[Solved] Text was truncated or one or more characters had no match in the target code page ole db source to flat file destination

I’m exporting a table output to a CSV file. I’m doing it using SSIS package which has OLE DB Source and Flat File Destination. I’m getting the following errors:

[Flat File Destination [2]] Error: Data conversion failed. The data conversion for column “Address” returned status value 4 and status text “Text was truncated or one or more characters had no match in the target code page.

“.

[Flat File Destination [2]] Error: Cannot copy or convert flat file data for column “Address”.

[SSIS.Pipeline] Error: SSIS Error Code DTS_E_PROCESSINPUTFAILED. The ProcessInput method on component “Flat File Destination” (2) failed with error code 0xC02020A0 while processing input “Flat File Destination Input” (6). 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.

[OLE DB Source [9]] Error: The attempt to add a row to the Data Flow task buffer failed with error code 0xC0047020.

[SSIS.Pipeline] Error: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED. The PrimeOutput method on OLE DB Source returned error code 0xC02020C4. The component returned a failure code when the pipeline engine called PrimeOutput(). The meaning of the failure code is defined by the component, but the error is fatal and the pipeline stopped executing. There may be error messages posted before this with more information about the failure.

Can anyone please advise?

Enquirer: ivric

||
Solution #1:

The output column for Address is specified as smaller than your original table column.

See this SO: SSIS data conversion failed

Summary:

(1) Right Click on Flat File Source and choose “Show Advanced Editor” Go to “Input and Output Properties “ Tab Expand “Flat File Source Output” and choose “External Columns”

(2) Select column “Address” and on right hand side, increase length to be same size as column in your original table

Double check anywhere in your Export wizard that allows you to set column sizes. Make sure those of your output file match those of your original table columns.

Respondent: user7396598
Solution #2:

@user7396598

Thank you for pointing me in the right direction. So I ran a comparison the records seem to be inserting in the same order only until a point then after they are not matching. I could captured the bad data. by running the following:
select * from table where address != cast(address as varchar(1000)), when I removed the bad data my SSIS packaged worked.

Now I need to figure out how to convert the bad data into acceptable format for the CSV.

Reference – https://stackoverflow.com/a/2683496/8452633

Respondent: ivric
Solution #3:

SO i had a similar problem of bad data in one of my columns causing this error even after increasing the size of the output column. In my case I solved this problem by replacing the bad data in my columns by using replace function.

I exported the data by writing a query and in that query instead of “select *” I wrote all the column names and used the replace function on the columns that were causing the problems. I replaced all the characters that could potentially cause truncation e.g. comma, pipe, tabs etc with an empty space.

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Leave a Reply

Your email address will not be published.