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

  • Chrissy321 (6/19/2013)


    Column1 is varchar(100). Column2 is varchar(50).

    WHERE CASE Column1 WHEN 'ABC' THEN 1 ELSE CONVERT(decimal(20,6),Column2)END) IS NOT NULL

    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.