skip 2 leading zeroes

  • I have a data field which has data like below

    00123456

    0012345

    00234234

    0098765

    00012345

    I need to manipulate the data to skip the leading zereos, regardless of the length

    So my result set should be

    123456

    12345

    234234

    98765

    012345

  • Does this help?

    create table #TestTab (

    Col1 varchar(12)

    );

    insert into #TestTab

    select '00123456' union all

    select '0012345' union all

    select '00234234' union all

    select '0098765' union all

    select '00012345';

    select

    right(Col1, len(Col1) - 2)

    from

    #TestTab;

  • Duh, thanks, afternoon brain freeze, i was going the whole substring road, making it way more complicated.

  • Will every row have at least two leading 0s?

  • yes

Viewing 5 posts - 1 through 4 (of 4 total)

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