Search

Saturday, November 5, 2011

String or binary data would be truncated

This error is coming due to:
You are doing INSERTing or UPDATEing a string column, but the length of the string you are passing in is too large.



Here is an example to recreate the problem.

create table Test  (Name VarChar(10))
INSERT INTO Test Values ('Manish') --This Works
INSERT INTO Test Values ('Manish Agarwal') --This Fails

You can use the SubString command to reduce the size of the input value to 10 characters such as this:
INSERT INTO Test Values (SubSting('Manish Agarwal', 1, 10)) 

No comments:

Post a Comment