What is meant by the error ‘String or binary data would be truncated. The statement has been terminated’?

String or binary data would be truncated

This is the common error in SQL Server when we are inserting or updating the data. When you are get this error for the first time, you will not be in a position to understand what it is :)

You get this error when you are trying to INSERT or UPDATE the data, whose length is more than the length of the column which you have defined in the table.

Ex:

Let us say, the DepartmentName column in Department table is defined as Varchar(5). But you are trying to INSERT ‘ABCDEFG’ value into DepartmentName column.

You will get this error since you are trying to INSERT a value whose length is 7 characters into the column which was defined as Varchar(5).

To resolve this error, reduce the length of the value which you are inserting or ALTER the table to increase the size of the DepartmentName column.

Leave a Reply

Your email address will not be published. Required fields are marked *