• One way to modify solution 2 to work with the mentioned operators (=, <>, > , <, IN) is to create the WHERE clause like this:

    WHERE (A.name = @Aname or @Aname = '') and (C.firstName like @Cfirst or @Cfirst = '') and (C.lastName like @Clast or @Clast = '') and (D.city like @city or @city = '') and (D.state = @state or D.state = '') and (D.phone like @phone or @phone = '')

    This solution removes the assumption that a NULL record is included. It also means that if you do not want to limit the result set by a city name simply send in @city = '' and that part of the WHERE clause will be completely ignored. It will just limit the result set on all other parameters that are not equal to ''.

    Robert Marda

    Robert W. Marda
    Billing and OSS Specialist - SQL Programmer
    MCL Systems