Home Forums SQL Server 2005 T-SQL (SS2K5) Error converting data type varchar to numeric in CASE statement RE: Error converting data type varchar to numeric in CASE statement

  • Try putting single quotes around the '1' or cast it as VARCHAR-- the expression is trying to compare a string ('ABC') with a numeric (1) and that will generate that error. The same issue occurs in JOIN statements. It seems SQL won't do implicit conversions in these cases and just throws an error.

     

    Same error. It seems implicit conversions can be a problem in CASE statement but something else is going on here.

    It seems to be the conversion and then the NOT NULL evaluation

    CONVERT(decimal(20,6), SomeVal) IS NOT NULL

    I pulled my CASE statement right out of the SELECT and put it in the WHERE clause. As Phil pointed out the CASE and the CONVERT was not needed in the WHERE clause.

    I'll plan on modifying my WHERE statements in case I get another dirty data load. I think we can put this to bed. Thanks everyone.