Msg 8114, Level 16, State 5, Line 3 Error converting data type varchar to float

4.1k views Asked by At

I am trying to apply a where clause my script is like

set ansi_nulls off

select
    Name, Count(Distinct [Document Name])
from 
    dbo.timeless
where 
    origin in ('2', 'I', 'E')
    and [svs check] IN ('0', '.', 'NO', 'OK', '#N/A')

Then I get the error

Msg 8114, Level 16, State 5, Line 3
Error converting data type varchar to float

When I comment out [svs check], everything goes fine. So the problem is in [svs check]. Kindly help.

1

There are 1 answers

0
Nathan On

I'm guessing dbo.timeless.svscheck is of type float and you can't compare it with string literals.

I suggest casting that to varchar first using CAST(svs as VARCHAR(10)) although I doubt that your where clause will work if it is really float, as you're checking it against string literals.