Why isn't "String or Binary data would be truncated" a more descriptive error?

Posted by rwmnau on Stack Overflow See other posts from Stack Overflow or by rwmnau
Published on 2010-03-30T18:24:52Z Indexed on 2010/03/30 18:33 UTC
Read the original article Hit count: 390

Filed under:
|
|
|

To start: I understand what this error means - I'm not attempting to resolve an instance of it.

This error is notoriously difficult to troubleshoot, because if you get it inserting a million rows into a table 100 columns wide, there's virtually no way to determine what column of what row is causing the error - you have to modify your process to insert one row at a time, and then see which one fails. That's a pain, to put it mildly.

Is there any reason that the error doesn't look more like this?

String or Binary data would be truncated
Error inserting value "Some 18 char value" into SomeTable.SomeColumn VARCHAR(10)

That would make it a lot easier to find and correct the value, if not the table structure itself. If seeing the table data is a security concern, then maybe something generic, like giving the length of the attempted value and the name of the failing column?

© Stack Overflow or respective owner

Related posts about database

Related posts about sql-server