T-SQL Tutorial

Msg 8152 Level 16 - String or binary data would be truncated


On Transact SQL language the Msg 8152 Level 16 - String or binary data would be truncated means that the length of the insert value is greater than the length of column.

Msg 8152 Level 16 Example:

We have the table TEST:

USE model;
GO
CREATE TABLE TEST(
   ID INT NOT NULL PRIMARY KEY,
   NAME VARCHAR(10) NOT NULL );
GO





Invalid insert:

USE model;
GO
INSERT INTO TEST(id, name) VALUES (1, 'Olivia Wilson');
GO

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

Correct insert:

USE model;
GO
INSERT INTO TEST(id, name) VALUES (1, 'Olivia');
GO

Message
(1 row(s) affected)

Other error messages: