Error Message:
Msg 8152, Level 16, State 14, Line 2
String or binary data would be truncated.
The statement has been terminated.
Some time this error is occurred when we insert data into database.Check the Database Column Size and Data length. you will get this error when you are storing data of length greater than that of defined size.
Example:-
string MyData = "Error Message: String or binary data would be truncated. The statement has been terminated.";
int Mydatalength = MyData.Length; // will be more than 30 characters , greater than defined size
Customer.Name = MyData;
//you will get error for this line.
Because you have Name (varchar 25, null) in Database if you want to solve this error just increase the size of name column in database.
Sql Query Example:-
DECLARE @EmpDetails TABLE(EmpId INT, Name VARCHAR(25),Designation VARCHAR(10))
INSERT INTO @EmpDetails(EmpId,Name,Designation)
VALUES(1,'Rajesh','Error Message: String or binary data would be truncated. The statement has been terminated.')
SELECT * FROM @EmpDetails
If you watch above query here Designation field is declare with VARCHAR(10) and we trying to inserting more than 10 characters because of that you got error like .
Msg 8152, Level 16, State 14, Line 2
String or binary data would be truncated.
The statement has been terminated.
DECLARE @EmpDetails TABLE(EmpId INT, Name VARCHAR(25),Designation
VARCHAR(500))
VARCHAR(500))
INSERT INTO @EmpDetails(EmpId,Name,Designation)
VALUES(1,'Rajesh','Error Message: String or binary data would be truncated. The statement has been terminated.')
SELECT * FROM @EmpDetails