This Error is very common when we insert or update data.
This error occurs when we try to insert data which is greater than the length of the column in which we are inserting the data.
For Instance : Lets see an example in our TSQL2012 database :
insert into [Production].Categories(categoryname,description) values ('No chocolate items','no chocolate')
It gave me an error :
Msg 8152, Level 16, State 4, Line 1
String or binary data would be truncated.
The statement has been terminated.
This happened because the Column Categoryname has the column type : nvarchar(15) , which means nvarchar can take upto 15 characters maximum. And the total length of characters tried to insert: ‘No chocolate items’ is of length 18 .
To solve this problem ,we can increase the length of column size to 18 . Or , we can reduce the characters accordingly to fit the size of 15 .
