More often when we work on Bulk Load or Importing lot of Excel or CSV files into SQL Server from external sources then we received the error “String or binary data would be truncated the statement has been terminated“. The reason is simple. One or some of your column value length exceeded the column length declared in the table. So first we nee to produce the error.
Create a table like below:
CREATE TABLE [dbo].[testTBL]( [ID] [int] NULL, [Name] [varchar](10) NULL ) ON [PRIMARY]
Now try to insert below record:
INSERT INTO testTBL VALUES(1, 'Shawpnendu Bikash Maloroy')
Got String or binary data would be truncated Error:
Error Heading: Msg 8152, Level 16, State 14
You have declared the table “testTBL” column “Name” length is 10. But you are trying to insert data with length>10.
Increase the column length by running the below SQL:
Alter TABLE testTBL ALTER Column Name VARCHAR(60)
Now insert the above record. Hope the error: Msg 8152, Level 16, State 14 – String or binary data would be truncated the statement has been terminated has been resolved.