• Get me? (2/26/2016)


    You have an OR condition. It's saying return rows that match OR where CONSIGNEE_DUNS is null.

    (CONSIGNEE_DUNS LIKE '%' + @conduns + '%') OR (CONSIGNEE_DUNS IS NULL) OR (CONSIGNEE_DUNS = '')

    What you should be doing is testing if the value of the Parameter is empty. It's the parameter that is optional.

    i.e. (@conduns = '' OR CONSIGNEE_DUNS LIKE '%' + @conduns + '%')

    Here you are saying if the parameter is empty ignore (short-circuit) the condition OR if it's not empty only return the row if it matches.

    Thanks very much for resolving this issue, it worked perfectly !