SQL exception: truncation error occurred while trying to compress VARCHAR '...' to length x

I really don't know much about sql, can anyone give me a deeper explanation (or links) of what this exception means?

- update

data to add to VARCHAR:

30819f300d06092a864886f70d010101050003818d00308189028181008942f81b3ae99e5f66dbc92cb971366f513c056e0bd6557c021058f6892d3a648230959c95378969f6dcb63046431fc0d39799789d307f96c811ae3836e43075e8cf21af84ce84f1e9c68773c9fbf03149f40248797a92562d55698dc7dce9f840bad0dfb47ccb982a2f015461cd5d38a3d6d75b349ce0bd89e3535ee8091ce70203010001

which have 325 characters.

And my VARCHAR has a size of 330 and throws this exception:

SQL exception: truncation error was encountered while trying to compress VARCHAR '30820276020100300d06092a864886f70d010101050548482603082025c &' to a length of 330.

(note that the VARCHAR indicated in the error message is different from the VARCHAR I'm trying to insert, I don't know why)

given these sizes, there cannot be more than a meter of my data than VARCHAR, as you can see.

What could be wrong?

- found

When preparing SSCCE, I realized that I was inserting the wrong data in the wrong place. Xd

+7
sql derby
source share
2 answers

This means that your VARCHAR field (variable-length string field) has a length of X, for example. 100, while the data you tried to insert was longer than 100 characters.

SQL Server will not automatically crop your data to the maximum length of the varchar field - you must be sure that you are not inserting more data than the field can hold.

+6
source share

Try decreasing the length in the query using CONVERT (data_type [(length)], expression [, style])

0
source share

All Articles