• I'm with Adam, check out MVP Erland Sommarskog's article on this: http://www.sommarskog.se/dyn-search.html

    However, for the example presented by the article, can someone tell me what's wrong with simply this?...

    select

    customerid, companyname, country

    from

    customers

    where

    (companyname LIKE @companyname) AND (country LIKE @country)

    This is able to deal with the different operators (NOT LIKE 'A%' can be dealt with by using '[0-9, b-z]%'), and can use indexes if they're there (i.e. avoid a table scan).

    Ryan Randall

    Solutions are easy. Understanding the problem, now, that's the hard part.