Astroc
Astroc

Reputation: 33

Conversion failed when converting the varchar value into int

I have the following problem. There is conversion problem in my database and this is a message I receive

Conversion failed when converting the varchar value '1589698' to data type int.

It's unusual because there is no extra signs and I work with these data for a long time but suddenly my procedures stopped working today. I tried to use convert and cast. I tried to retyped the number and each time I have the following error.

Upvotes: 1

Views: 1681

Answers (1)

DavidG
DavidG

Reputation: 118947

As shown by this screenshot:

enter image description here

you have an errant character on the end of the varchar column. That character is what causes the conversion to fail.

You need to do two things:

  1. Remove that character to allow the process to work again.
  2. Always validate your input! This value should never have made it into your database in the first place.

Upvotes: 2

Related Questions