Calculation with Alphanumeric Values

  • Hi

    how to achieve the calculation between two alphanumeric charactered field's value?

    we enter only decimal numbers to tht alphanumeric field. but while trying to subtract both the error, 'Invalid operator to alphanumeric value' is thrown

    how to calculate? kindly help

  • New Commer (7/18/2008)


    Hi

    how to achieve the calculation between two alphanumeric charactered field's value?

    we enter only decimal numbers to tht alphanumeric field. but while trying to subtract both the error, 'Invalid operator to alphanumeric value' is thrown

    how to calculate? kindly help

    You can use cast to convert to numeric type.

    E.g.

    select cast('123' as int) - cast('123' as int)

    Regards,

    Andras


    Andras Belokosztolszki, MCPD, PhD
    GoldenGate Software

  • It will be much better to check your alphanumeric values with ISNUMERIC() function before applying mathematical functions.

    After that, use CAST for conversion to get the job done.

    This way, you will always apply mathematical operation on the numeric values converted from the char / varchar. For incorrect alphanumeric, values, you cag generate message to avoid an error.

    Atif Sheikh

    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Sometimes, winning is not an issue but trying.
    You can check my BLOG
    [font="Arial Black"]here[/font][/url][/right]

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply