Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to see in which column data truncation has happened

Inserting data into a Microsoft SQL Server database using Java, I got an SQL truncation exception. But the exception doesn't show which column had the problem value.

Is there any way to find the error details, for instance from SQL Server Management Studio?

Note: I am using SQL Server database in Windows.

like image 496
Rajasekhar Avatar asked Jan 25 '13 06:01

Rajasekhar


1 Answers

Unfortunately, no. The error message is as much information as SQL Server will give you.

To discover what values in what columns of which rows are at fault, you need to analyze the data. A common approach to discovering this sort of issue is to perform binary chops - remove half of the data or half of the columns, attempt the insert again (possibly into a temp table with the same structure as the real table) and see if the error recurs.

If it does, great, at least one problem is in the data that remains. If not, then you've eliminated half of the data as not causing a problem.

like image 80
Damien_The_Unbeliever Avatar answered Nov 03 '22 10:11

Damien_The_Unbeliever