“Msg 8152, Level 16, State 4, Line 1 String or binary data would be truncated. The statement has been terminated.”
If you try to insert more characters than the character length of the column in a table, you will encounter this error and the insert will be canceled.
For example, you have a table named “myTable” and its schema is as follows:
CREATE TABLE myTable
(ID Int Identity(1,1) PRIMARY KEY,
If you try to insert data into this table as follows, there will be no problem.
INSERT INTO myTable VALUES('Ekrem', 'Onsoy')
But if you try to insert a data as follows, you will get an error:
INSERT INTO Tablom VALUES('Abdulrezzak', 'Önsoy')
Because the name “Abdulrezzak” exceeds the length of 10 characters we assign to the “Name” column when creating the table. Therefore, data cannot be saved and the operation results in this error.
Increase the width of your column. For example, if we continue from the example above, we will not have a problem with the name “Adbulrezzak” if we set the “Name” column as nvarchar (15). You can set a larger value to suit your needs.
You can use the below script. You dont need to recreate the table to increase the width of the column.
ALTER TABLE myTable ALTER COLUMN Name nvarchar(15)