• saurabh.dwivedy (4/29/2009)


    Just wanted to mention a small point here: Your code assumes that the starting position will always be 1. What happens if the match string were to be somewhere in the middle? For ex, if there was another number such as 98954412

    in the input table, the code above will not be able to detect this because its patindex is > 1

    If the match string can also be in the middle (which is not clear by the data / description provided by the OP), the PATINDEX function needs just a small modification:

    Instead of checking for = 1 it needs to check for >0. This will include any matching values.

    However, the data provided by the OP did indicate that a check for position 1 is required...



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]