Wednesday, August 31, 2016

String or binary data would be truncated

Whenever we are trying to insert data from one table to another we might face below error:
Msg 8152, Level 16, State 13, Line 2
String or binary data would be truncated.
The statement has been terminated.

Use MAX(LEN(Column Name)) function to check the maximum length of data which we are trying to insert into the column. 

If we are trying to insert character length of 27 into a column defined as Char(25) we will face this error. 

Now either use substring function to cut the length of the data to 25 characters or change the column width to maximum width of data we are trying to insert!

No comments:

Post a Comment