• meadow0 (3/20/2013)


    I find the article conceptually and technically difficult to understand as I've only been working with SQL for about two weeks. I will certainly attempt to give it a read if it'll be that beneficial. Thanks

    Understood. It is pretty technical and the topic is certainly advanced. Kudos to you for not only reading it but also not blindly using it because some guy on the internet said "it was best".

    The performance problem you will run into is called SARGable. This comes from "search argumentable".

    Think of your queries as though it is you looking through the phone book.

    With what you are doing you want to find any of a list of possible values and those values are contained in a larger string. To use the phone book example you would have to look at every single name in the phone book to determine if the name is in your string. If instead you first parse your string you are no looking for absolute values. This means that sql can use its built in indexing. So if you don't have a value in your list that begins with the letter 'a', it won't even look in that part because it would be a waste of time. It can also find values like 'smith' far easier. It doesn't have to start with the first page and keep going until it finds smith. It will instead skip ahead large chunks of pages because searching the pages prior to that are pointless. Not sure if I am explaining this well, but hopefully you get the idea.

    If you want some help with coding this you will need to post some ddl (create table scripts), sample data (insert statements) and desired output based on your sample data. The first article in my signature gives several example of the best way to post this stuff.

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/