• Try changing this:

    si.TrackingNumber like '%' + @SearchText +'%'

    to this:

    si.TrackingNumber IS NOT NULL AND si.TrackingNumber like '%' + @SearchText +'%'

    And if that helps, read this article to see why:

    Improving Performance for Some LIKE “%string%” Searches[/url]

    If you see a performance improvement gain, it will be dependent on how many NULL values are in that column (the more the better).

    There are also some other things you could also try:

    - change the order of your queries so that the si table is first (left-most table in the JOINs).

    - change the odd JOINs that aren't on common table criteria to CROSS APPLY

    And of course, remove the NOLOCK hints unless you're aware of the dangers of using it.


    My mantra: No loops! No CURSORs! No RBAR! Hoo-uh![/I]

    My thought question: Have you ever been told that your query runs too fast?

    My advice:
    INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
    The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.

    Need to UNPIVOT? Why not CROSS APPLY VALUES instead?[/url]
    Since random numbers are too important to be left to chance, let's generate some![/url]
    Learn to understand recursive CTEs by example.[/url]
    [url url=http://www.sqlservercentral.com/articles/St