Friday 15 April 2016

SQL string or Binary data would be truncated .The statement has been terminated.



When you found an error like ‘SQL string or Binary data would be truncated .The statement has been terminated.’  in sql.

This error occurs due to size of datatype of that column in which you want to insert.

Example:-  

Declare @Employee table(Id int,EmpName varchar(20),EmpCity varchar(20))

Insert into @Employee(Id,EmpName,EmpCity)
Select 1,'Sushilkumarmodi123324','BLR'

When you try to insert more than 20 char in EmpName column then SQL will through a error like below.

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

To resolve the error increase the size of that column. If you know the maximum size of the column then ok, if not then give max size like varchar (max).

No comments:

Post a Comment

Note: only a member of this blog may post a comment.