It is probably trying to convert the char phone number to decimal in order to the comparison. It can’t convert it to a number if it has other than numeric digits in it, therefore it gets the error (how would you expect it do to that?). So what I suggest is that you cast the decimal version to a char string and compare the two strings instead. It would probably still not do what you want, but it won’t error. What you need to do is to cleanup the char version of the phone number so that it has only numeric data.