Skip to content
Advertisement

Conversion failed when converting the varchar to numeric and displaying numeric values only

got an error

converting data type varchar to numeric.

when tried to convert numeric to varchar but that is also an error

Conversion failed when converting the varchar value ‘7.350000’ to data type int.

Advertisement

Answer

I strongly recommend case instead of iif(), but it is the same problem. The expression refers to a single value, with a single type. If one branch (“then”) is a number and the other a string (“else”), then the result is a number.

So, convert the number to a string:

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement