• Register
0 votes

Problem :

I want to import the flat file into my oledb target sql server database.

But I am getting below error message :

[Source - 18942979103_txt [424]] Error: Data conversion failed. The data conversion for column "recipient-name" returned status value 4 and status text "Text was truncated or one or more characters had no match in the target code page.".

Why am I getting this error message? What am I doing wrong here?

6 5 3
7,540 points

Please log in or register to answer this question.

2 Answers

0 votes

Solution :

I tried to increase the length and also tried to change the data type to text but it was not working for me. But after creating an XLSX file and importing it worked for me. It accurately detected my data type instead of setting all columns as varchar(50). The nvarchar(255) for my column would have worked too.


I solved my problem by just ORDERING the source data (xls, csv, whatever) in such a way that my longest text values kept on the top of my file. Excel approach is great. You can use the LEN() function on your challenging column. You can order by that length value with the longest value on top of the dataset. Save it. And just try the import again.

It worked for me, hope it works for you too.

9 7 4
38,600 points
0 votes


I know this is an old question. The way I solved it - after failing by increasing the length or even changing to data type text - was creating an XLSX file and importing. It accurately detected the data type instead of setting all columns as varchar(50). Turns out nvarchar(255) for that column would have done it too.

1. On the OLE DB Source Editor - Error Output - Choose "Redirect Row" on the Column that is causing the failure
2. Add a new Flat File Destination text file to store the redirected rows
3. On the Data Flow Path Editor leading to the main output file - Data Viewers - Add a new OLE DB Source Output Data Viewer (Grid). Ensure the issue column is in the Displayed Columns list

At this point the SSIS package is now configured to re-direct any failed rows to a separate error log file.
Also enabled is a Debug Visual of the rows as they are loading (Data Viewer).

The issue with this package was only 4000 of the ~70000 rows were being sent to the main text output file. Checking this output file shows a partially loaded row at the end of the file. Querying the db showed a number of invalid characters in that row.
Remove the invalid characters or exclude that row from the results set to get the SSIS working again.

Another Method

Convert all the char or varchar fields in the SELECT list in your stored procedure to nvarchar()
Then change the SSIS Flat File Connection Manager Code Page to "65001 (UTF-8)".
Then ensure the SSIS Data Flow Path Editor..Metadata..Code Page = 0 (not 1252 which is ANSI))
This makes the db return Unicode data and the output file is also Unicode/UTF-8
(UTF-8 is a character encoding capable of encoding all possible characters, or code points, in Unicode. The encoding is variable-length and uses 8-bit code units)

Also, confirm your output file us indeed in UTF-8 encoding. Open the file in Notepad, click 'Save As...', in the 'Encoding:' box you will see the current file format.

Or you can follw below steps

1. When the "Choose a Data Source" window pops up,
2. On the left-hand side, there is a column called "Advanced". (The wizard only allows you to click on "Advanced" when there is a Data Source selected already)
3. Click on the Advanced, another window shows up, on the right hand-side there is a column called "Msc",
4. Change the DataType in the dropdown menu to "text stream [DT_TEXT]".

N.B: This error happens when you have created a table with different columns containing different Data Type and you try to import data mapped to the column with different Data Type. In the video below, you will see the demonstration to attemp to import data to a table with changed column data type.

10 6 4
31,120 points

Related questions

0 votes
1 answer 7 views
Problem: I get the following red-warning message on the screen Text was truncated or one or more characters had no match on the target code page What am I doing wrong? Thank you
asked Mar 21 ummesalma 25.2k points
0 votes
1 answer 22 views
Problem column name or number of supplied values does not match table definition
asked Feb 9 charles mathews 5.5k points
0 votes
1 answer 6 views
Problem: I need help in resolving this problem: Which type of join returns rows from one table that have no direct match in the other table?
asked Apr 1 rakib1 51.5k points
0 votes
1 answer 22 views
0 votes
1 answer 2 views
Problem: Please assist me in resolving this issue: Return all rows when there is a match in one of the tables.
asked Mar 29 tuhin1 48.9k points
0 votes
1 answer 251 views
Problem : My stored procedure giving me following error cannot perform an aggregate function on an expression containing an aggregate or a subquery.
asked Nov 15, 2019 peterlaw 6.9k points
0 votes
1 answer 9 views
0 votes
1 answer 5 views
Problem: I was always of the impression that a query with no specified 'Order by' rule, would order this by the results by what was specified within your where clause.
asked Mar 14 ummesalma 25.2k points
0 votes
1 answer 2 views
Problem: Please help me to solve it. What does != mean in sql?
asked Apr 3 Ifra 24.4k points