query to get a part of strin

  • Cory E. (5/7/2010)


    This is why we are looking for requirements.

    Heh.... I understand the lesson in progress but I thought the requirements were actually pretty clear on this one. From the OP...

    column1

    \\abc\tri\eds\rf

    \\fd\tri\ef\\ghij\tri\gf\rf\k

    '

    '

    '

    i got some rows like that in a column

    now i want to get the result set like

    \\abc\tri\eds

    \\fd\tri\ef

    \\ghij\tri\gf

    simply from first '\' to end of 4th '\'

    ... and you can easily infer (or ask the question) that if there is no 4th '\', then you need everything.

    --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)
    Intro to Tally Tables and Functions

  • [/quote]

    Heh.... I understand the lesson in progress but I thought the requirements were actually pretty clear on this one. From the OP...

    [/quote]

    Yeah - when looking at just this post, it is pretty clear. When you look at both his posts within a couple hours of each other, they are very similar, but have different requirements. I had offered help on the first post, and second post. Either way, you are correct, for this question, the requirements were clear.

    -- Cory

  • The lesson here was not requirements, but what the OP has done to solve the problem presented. I asked this as this post is similar, yet different, from another post by the same OP.

  • @string=\\abc\tri\eds\rf

    i used substring(@string,charindex('\', @string),charindex('\',@string,charindex('\',@string,charindex('\',@string,charindex('\',@string,charindex('\',@string)+1)+1)+1)+1)

  • Lynn Pettis (5/8/2010)


    The lesson here was not requirements, but what the OP has done to solve the problem presented. I asked this as this post is similar, yet different, from another post by the same OP.

    Like I said... I understand the lesson in progress across both posts here. 😉

    --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)
    Intro to Tally Tables and Functions

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

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