Microsoft SQL Server Error: SQL SERVER – Msg 8152, Level 16, State 14 – String or Binary Data Would be Truncated

Microsoft SQL Server Error: SQL SERVER – Msg 8152, Level 16, State 14 – String or Binary Data Would be Truncated

Details of Error:

String or binary data would be truncated. The statement has been terminated.

This error message below occurs when part data is been truncated while loading a table.

Actual error message:

Msg 8152, Level 16, State 14, Line 8
String or binary data would be truncated.
The statement has been terminated.

Resolution:

Either Shortened the data which is being truncated or increase length of the column on the Table or use below statements at the top and bottom of sql insert statement which is suppress the error

SET ANSI_WARNINGS OFF;
-- Insert TSQL here.
SET ANSI_WARNINGS ON;

By using Andi_Warnings off, the error will be suppressed in the above code, but we lost part of the actual data which we were supposed to have on the table. So be cautious when working with such SET options.

Additional information below:

Use ANSI_WARNING OFF with care as sometimes important data can be truncated or lost. Also has negative impact on performance of insert statement.

Leave a Reply

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