SQL Error:String or binary data would be truncated.

While inserting Json Data in the table we are getting this error. The field in Table where JSON is getting stored has length of 25000 and while inserting the data,it is only of 2000 but still this exception is coming.

String or binary data would be truncated.
The statement has been terminated.
Environment Information

Hi Richa,

Did you check json format once?

Try to insert that json format directly to database using sql query. Please let us know the output.


Rajat Agrawal

Alternatively you could define your entity attribute as binary (blob in database) and use the text to binary function to convert the json to binary prior to saving it in the entity. Benefit of this is that you have no size limit.

I agree with Daniel..



Hello Richa,

If you create an attribute of type text, in an entity, with less than 2000 characters, it will be created with a certain data type that accepts 2000 characters at maximum. If later you change the size of the attribute to more than 2000, the data type is not changed. So, while you think you can store more than 2000 characters, the database will not allow it.

The workaround is to create a new attribute with the desired size and start using it instead of the old one.
If you don't have data, you can delete the old one. If you have, you can create logic like a bootstrap to copy from the old attribute to the new one.