Right there is the issue… however you added the value to the DB it ended up as a 5 character string. It should have been an integer. Even a string would would work if it was
varstring(3) "662". Notice that instead of
5 it says
3. The number is the number of character in the string.
Adding the trim, although will “fix” the real source of the error is the value in the DB. I would recommend simple correcting the source value rather than trying to clean it up after the fact.
In any event, great to see you rooted out the issue.