SQL Server Export : “Text was truncated or one or more characters had no match in the target code page”


I recently did an export from a database table on a thirds party website we host, from the news letter table- Using the standard SQL Export dialogue in sql server management studio 2008, i selected to export to a flat file- i pasted in my query and adjusted the column mappings then hit finish only to be confronted with an error mid way through the export;

Copying to C:\Users\Shaw.Young\Desktop\bq-newsletters1.txt (Error)
Messages
Error 0xc02020a1: Data Flow Task 1: Data conversion failed. The data conversion for column “surname” returned status value 4 and status text “Text was truncated or one or more characters had no match in the target code page.”.
(SQL Server Import and Export Wizard)

Error 0xc02020a0: Data Flow Task 1: Cannot copy or convert flat file data for column “surname”.
(SQL Server Import and Export Wizard)

Error 0xc0047022: Data Flow Task 1: SSIS Error Code DTS_E_PROCESSINPUTFAILED.  The ProcessInput method on component “Destination – bq-newsletters1_txt” (46) failed with error code 0xC02020A0 while processing input “Flat File Destination Input” (47). 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.
(SQL Server Import and Export Wizard)

Error 0xc02020c4: Data Flow Task 1: The attempt to add a row to the Data Flow task buffer failed with error code 0xC0047020.
(SQL Server Import and Export Wizard)

Error 0xc0047038: Data Flow Task 1: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED.  The PrimeOutput method on component “Source – Query” (1) 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.
(SQL Server Import and Export Wizard)

Export - Choose Destinatino Dialogue

Export - Choose Destinatino Dialogue

I checked the mapping for the surname field, and at 100 characters it was the same as the field length so this wasn’t truncating, which left me with the codepage issue.  This is easily fixed by simply changing the encoding of the flat file all the way back on the Choose a Destination tab- Mine defaulted to “1252 (ANSI – Latin I)” so i changed it to “65001 (UTF – 8)” and this fixed the problem.  Really simple, but I’d actually never come across this before when doing an export so figured I would blog it.

  1. #1 by arun on March 23, 2012 - 03:50

    thanks for this tip fixed my errors tooo

  2. #2 by bhumi on July 2, 2012 - 06:15

    i also face same type of errors given above….i have tried to change the length of the column width and also data type but same error i get again and again….please help me how to fix this error….

    thank you

  3. #3 by shawson on July 2, 2012 - 09:03

    Did you try changing the codepage as mentioned above?

  4. #4 by page one on google on October 6, 2012 - 14:40

    It is funny just how many sites the internet has about this subject I don’t know if I’m ever going to
    need to come back, but it is awesome to know I found the one that provides some valuable info if this comes up for me another time.

  5. #5 by M on January 13, 2016 - 01:11

    Genius! Changing the code page from the default to UTF-8 is the answer.

  6. #6 by Theodore on January 18, 2016 - 20:33

    Thanks so much – this solution solved my problem. I was really banging my head on the wall. It’s such a relief to see this package execute with no errors! Thanks again.

(will not be published)