Substring from RIGHT

  • Understood. You missed the reason why I asked the question. I'll try to be more specific in the future.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • DECLARE @valVARCHAR(30)

    SELECT @val = '9.0.0832.1032'

    SELECT @val

    SELECT SUBSTRING(@val, LEN(@val) - 6, 2)

    Steve Jimmo
    Sr DBA
    “If we ever forget that we are One Nation Under God, then we will be a Nation gone under." - Ronald Reagan

  • sjimmo (8/10/2016)


    DECLARE @valVARCHAR(30)

    SELECT @val = '9.0.0832.1032'

    SELECT @val

    SELECT SUBSTRING(@val, LEN(@val) - 6, 2)

    That will work but only if you only ever need the right 2 of the 3rd element and only if the 4th element will always have 4 characters. Unfortunately, we may never know because the OP seems to have flown the coop and hasn't participated in his own question (asked 5 months ago) never mind the questions that others have asked about the consistency of the data format.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Thanks Jeff. I was simply offering an alternative. Should have looked more closely at the dates. :hehe:

    Steve Jimmo
    Sr DBA
    “If we ever forget that we are One Nation Under God, then we will be a Nation gone under." - Ronald Reagan

  • sjimmo (8/11/2016)


    Thanks Jeff. I was simply offering an alternative. Should have looked more closely at the dates. :hehe:

    Absolutely understood and alternatives are great. I appreciate your post even if it were on a decade old thread because methods change and alternatives are sometimes better. I'm just a wee bit ticked that the OP never came back on the questions at hand.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 5 posts - 16 through 19 (of 19 total)

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