Everything to the right of the Last Zero

  • mbrady5

    SSCrazy

    Points: 2835

    Hi,

    Can  I have some assistance? I'd like to retain all of the characters to the right of the last zero from left to right.
    Here are a few examples. The location is not  the same all of the time.
    VO0100005 100005

    VO0101553 101553

    VO0099300 99300

    In the above, the end result should be what's to the right of the string that start with 'V'

    Thanks

  • Bill Talada

    SSChampion

    Points: 11956

    Does this meet your needs?


    DECLARE @t table (vin varchar(10) NOT NULL);
    INSERT into @t VALUES ('VO0100005'), ('VO0101553'), ('VO0099300');
    SELECT vin, CAST(REPLACE(vin,'VO','') AS int) FROM @t;

  • mbrady5

    SSCrazy

    Points: 2835

    Yes, this is great. Thanks

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

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