Error converting data type varchar to float

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jaYPee

    Error converting data type varchar to float

    I have created a stored procedure that contain this field (below) in
    order to meet certain criteria. But my problem is when I try to run
    the stored procedure I encounter an error "Error converting data type
    varchar to float".

    CASE Final WHEN 0 THEN '--' ELSE Final END AS FinalGrade

    The Final field is a float data type.

    Could anyone teach me how to fix this problem?
  • Tzvika Barenholz

    #2
    Re: Error converting data type varchar to float

    Hi JayPee

    You case statement is illegal because '--' is actually a varchar.
    what do you want the return to be ? what is the function.

    you could cast final as varchar and then return something like

    when '0' then '--' else cast(final as varchar)

    or if you need to keep it as float, i suggest putting null instead of
    '--' and then running is_null on that.

    hope this helps
    Tzvika

    Comment

    Working...