tags:

views:

36

answers:

2

I am developing a SSIS package, trying to update an existing SQL table from a CSV flat file. All of the columns are successfully updating except for one column. If I ignore this column on truncate, my package completes successfully. So I know this is a truncate problem and not error.

This column is empty for almost every row. However, there are a few rows where this field is 200-300 characters. My data conversion task identified this field as a DT_WSTR, but from what I've read elsewhere maybe this should be DT_NTEXT. I've tried both and I even set the DT_WSTR to 500. But none of this fixed my problem. How can I fix? What data type should this column be in my SQL table?

Error: 0xC02020A1 at Data Flow Task 1, Source - Berkeley812_csv [1]: Data conversion failed. The data conversion for column "Reason for Delay in Transition" returned status value 4 and status text "Text was truncated or one or more characters had no match in the target code page.".
Error: 0xC020902A at Data Flow Task 1, Source - Berkeley812_csv [1]: The "output column "Reason for Delay in Transition" (110)" failed because truncation occurred, and the truncation row disposition on "output column "Reason for Delay in Transition" (110)" specifies failure on truncation. A truncation error occurred on the specified object of the specified component.
Error: 0xC0202092 at Data Flow Task 1, Source - Berkeley812_csv [1]: An error occurred while processing file "D:\ftproot\LocalUser\RyanDaulton\Documents\Berkeley Demographics\Berkeley812.csv" on data row 758.
+1  A: 

I suspect the or one or more characters had no match in the target code page part of the error.

If you remove the rows with values in that column, does it load? Can you identify, in other words, the rows which cause the package to fail? It could be the data is too long, or it could be that there's some funky character in there SQL Server doesn't like.

Beth
Beth, like I said above when I ignored truncates for this one column then all of these records were updated.
salvationishere
OK, so you've looked at the rows and don't see anything unusual about them. It could be the length instead. Can you copy the data from one of the failing rows into the table manually? It might give you a more meaningful error message.
Beth
How would I copy data from Excel to SQL for these failing rows?
salvationishere
Write an insert statement. The idea is to get it working outside of SSIS. SQL will probably give you a better message, or at least isolate the problem for testing.
Beth
I'm sorry Beth; I know how to write an insert statement for SQL data but not for Excel. How can I do this?
salvationishere
You want data from the csv to go to the sql server, right? So you identify a row in the csv file causing the problem, then instead of inserting with ssis, insert with an sql statement using mgmt studio.Using Excel for the csv is ok, but Notepad should work, too, unless it's too big.
Beth
+1  A: 

One possible reason for this error is that your delimiter character (comma, semi-colon, pipe, whatever) actually appears in the data in one colum. This can give very misleading error messages, often with the name of a totally different column.

One way to check this is to redirect the 'bad' rows to a separate file and then inspect them manually. Here's a brief explanation of how to do that:

http://redmondmag.com/articles/2010/04/12/log-error-rows-ssis.aspx

If that is indeed your problem, then the best solution is to fix the files at the source to quote the data values and/or use a different delimeter that isn't in the data.

Pondlife
Thanks, but my manager just informed me that we no longer need this table/file!
salvationishere