Text was truncated or one or more characters had no match in the target code page ole db source to flat file destination
Asked Answered
Y

3

0

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?

Yser answered 14/5, 2018 at 20:55 Comment(3)
SSIS errors stack on top of each other. What's the earliest error in this stack? That should lead you to the problem. I'd guess this is a data conversion issue or perhaps there is a field in your destination table that is too small for the data you are trying to import.Dalessandro
the earliest error was he 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." My destination is a flat file (.csv)Yser
Check your mappings make sure all fields are correctly delimitedDalessandro
N
2

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.

Naive answered 14/5, 2018 at 21:18 Comment(6)
Thanks, But still facing the same issue. I tried and made sure the table column length for Address' (set to 100) is same as the one being specified in the SSIS package. The column datatype on the table is set to nvarchar(100) and on the SSIS package its set to Unicode string [DT_WSTR] and Length=100. also to mention, my source is OLEDB Source and destination is the Flat file which i'm writing to.Yser
@Yser Double check that you do not have a non-unicode symbol in any of your Address values in the database. The most obvious culprit is the column size, but if that is correct and you're still getting the same error code, you have data that is not recognized in the output encoding.Naive
I think maybe its the data then, but is they any way i could check that ?Yser
Also to add, I have some records being inserted in the csv flat file.Yser
@Yser Are the records inserted in the same order as those in the origin table? If so, look at the address for the first entry that does not get written into the file. It probably has some character(s) that cannot be encoded using the output encoding.Naive
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. Nevertheless I got to a point where I figured outYser
Y
1

@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://mcmap.net/q/121501/-how-can-i-find-unicode-non-ascii-characters-in-an-ntext-field-in-a-sql-server-2005-table

Yser answered 15/5, 2018 at 20:45 Comment(1)
Figure out where the bad data came from. If was through an application that writes to your database you may want someone to address a way to filter similar data in the future.Naive
S
0

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.

Superelevation answered 11/4, 2019 at 5:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.