views:

1187

answers:

4

So I am trying to do a bulk insert with SSIS and continually get:

"Microsoft SQL Native Client" Hresult: 0x80004005 Description: "String or binary data would be truncated."

Even though I already have a data conversion for every column into the exact same type as the table that the rows are getting inserted into. I used a view and the data looks like it supposed to just before the DB insert step. Still get the error.

Next I went into sql server management studio and setup an insert query into that damned table and still get the same truncation error. I then did a set ANSI_WARNINGS OFF and the insert works data looks good in the table. Now when I try to delete this row I get the Truncation error.

My question besides any basic input to the situation is how can I turn off the ANSI_WARNINGS within SSIS so that the bulk load can go though?

+1  A: 

Are there triggers on the table you're inserting into? Then the error may come from an action that the trigger takes.

John Saunders
How can I tell which of the 3 triggers is fired when I run SSIS or when I try to just do the plain sql query insert of 1 row?
Andrew Jahn
I'm not sure whether that little detail shows up in the error information. I would check all three, but then, I'm not an expert-level SQL developer.
John Saunders
+1  A: 

It sounds like you have a column that is too narrow to accept the data you are submitting.

Can you verify if this is or isn't the case?

I had a very similar issue arise frequently while we were nailing down a schema with a third party.

Can you select a LEN of all of the columns in the view? That could help find the issue.

Other than that, the only way I have found is to print out a report of the actual lengths of the source data columns.

John Gietzen
+1  A: 

Sounds like you've got one row (possibly more, but it only takes one!) where your data value exceeds the length of the table columns. Doing a data conversion to the shorter type will MOVE the error to whatever transform does the conversion from the Destination. What I'd recommend is creating a Flat File Destination, and tying the error output of your transforms to it. Change the error result to 'Redirect Row'. This will allow all the valid rows to go through, and provide you with a copy of the row(s) that are getting truncated for you to manually handle.

Harper Shelby
I setup the redirect row and every row fails with the truncation error and is put in the flat file showing which rows failed insert.
Andrew Jahn
Are you getting the 'Error Column' with a meaningful value? Not all components provide that, so it's not often helpful, but if it's there it is. Also, check the metadata on the inputs and outputs - sometimes that's not refreshed correctly, and deleting/readding will fix an issue.
Harper Shelby
A: 

Turns out that in SSIS you can setup the OLE DB Destination with "Data Access Mode > Table or view: Fast Mode". When I chose this setting the bulk insert went through without any warnings or errors and the data looks perfect in the database. Not sure what this change did exactly but it worked and after 16hours on one SSIS insert I'm happy with results.

Thanks for the suggestions.

Andrew Jahn
That mode will have turned off your triggers, most likely. If you didn't need them, you're fine. Check with your DBA, as they may have been necessary (as they are on the project I'm working on now).
John Saunders
lol I'm the DBA, its a smaller shop and I'm doing the best I can. I'm more or less just managing and filling up our DB. This company never actually had any DBA's at all.
Andrew Jahn