Remove first character and add trailing zero

  • y data in column A look like:

    -0002

    00030

    -0004

    00050

    I need to remove the first character '-' when occurs and then add a trailing zero so result is:

    00020

    00030

    00040

    00050

    Thank You for your help

    HM

  • Replace the field and table name with your own and this should get you close:

    select

    (case LEFT([Value], 1)

    when '-' then substring([Value], 2, LEN([Value])-1) + '0'

    else Value

    end) as ValueNew

    from dbo.[Values]

    order by Value

    Mark

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

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