====== Microsoft - Microsoft SQL Server - SQL - Insert - Truncated Insert ====== ===== Create a test database ===== Create Database TestDB Go Use TestDB Go CREATE TABLE TestTable ( [ID] INT identity(1,1), [NAME] VARCHAR(10), ) GO ---- INSERT INTO TestTable VALUES ('Some dummy data') GO INSERT INTO TestTable VALUES ('Some more dummy data') GO returns errors: SQL truncate error message ‘String or binary data would be truncated.’ ---- ===== Check the length of the string that is being inserted ===== select len('Some dummy data') as [StringLength] Select len('Some more dummy data') as [StringLength] **NOTE:** This should return 15 and 20. * These are both longer than the length of the NAME field which caters for 10 characters. ---- ===== Check the length of the Name column ===== select character_maximum_length,column_name from information_schema.columns where table_name = 'TestTable' and Column_name='NAME' returns: 10 ---- ===== Solution ===== SET ANSI_WARNINGS off GO INSERT INTO TestTable VALUES ('Some dummy data') GO INSERT INTO TestTable VALUES ('Some more dummy data') GO SET ANSI_WARNINGS on GO