Everything to the right of the Last Zero

  • 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

  • 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;

  • Yes, this is great. Thanks

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

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