[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 604
  • Last Modified:

String or binary data would be truncated - Determining Which Field ?

During the import of a table with about 80 columns and 1 million rows, I've received the error that "String or binary data would be truncated" ... however, SQL 2005 doesn't tell you which column is being truncated.  

Is there any way to determine this, perhaps more robust error message options, etc.?  A setting somewhere in SQL that will give more details?  Or an error log I'm not aware of that would tell me more information?

I know how to fix the error itself ... my question is about getting more information out of SQL as to what the exact error was.

Thanks


0
drgdrg
Asked:
drgdrg
  • 2
2 Solutions
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
>however, SQL 2005 doesn't tell you which column is being truncated
yes, sadly enough. even worse, if your statement triggered some trigger, and the problem occured there, you could search long time in the table/code without finding the problem...

>Is there any way to determine this, perhaps more robust error message options, etc.?  
not really. double-checking any triggers, and making sure any user input is limited (or cut) at the defined field length, and/or increasing field sizes.
0
 
RiteshShahCommented:
I guess there is not short and sweet way of doing so other than just checkout all string column with it's size and comparing it with the data your inserting or updating.
0
 
Jagdish DevakuSr DB ArchitectCommented:
hi...
the error clearly says that you are inserting data longer than the solumn size.
if you are aware of the length of the data that you are inserting then you can find the column using the below query.
i think from the event viewer or from sql server logs you can get more info.
bye

select * from information_schema.columns
where character_maximum_length < ?length of the data? and table_name = '?table_name?'

Open in new window

0
 
RiteshShahCommented:
I guess nothing can show you which column is culprit.
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now