Checking sequence of codes

  • Hi Jeff

    Thanks for the input.

    The code I'm (trying to) write needs to check the sequence of the codes in post #1.

    I don't think the code I posted from my WHERE clause is quite right (although I think the theory is sound).

    I'd be grateful for any advice you could give.

  • Have you tried going for a fancier pattern? If all you want is to find the pattern, no sense in parsing the string

    I kind of think this is what you want:

    select code from #test where patindex('%Q2[234]%Q0[78]%',code)>0

    ----------------------------------------------------------------------------------
    Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?

  • Thanks Matt

    That looks to have done the trick.

    I'll have to double-check but it looks good at first pass.

  • richardmgreen1 (9/16/2014)


    Thanks Matt

    That looks to have done the trick.

    I'll have to double-check but it looks good at first pass.

    I'll second Matt's solution over splitting the data. Even if you use a CLR to do the split, it'll still be really expensive compared to Matt's solution.

    --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 4 posts - 16 through 18 (of 18 total)

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