Site icon Database Tutorials

“Msg 8152, Level 16, State 4, Line 1 String or binary data would be truncated. The statement has been terminated.”

 

ERROR MESSAGE:

“Msg 8152, Level 16, State 4, Line 1 String or binary data would be truncated. The statement has been terminated.”

 

EXPLANATION:

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:

If you try to insert data into this table as follows, there will be no problem.

But if you try to insert a data as follows, you will get an error:

 

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.

 

SOLUTION:

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.

Exit mobile version