• This sounds like a 'catch-all' query and can be achieved with dynamic SQL.

    Have a look at the below for an excellent description and examples:

    http://sqlinthewild.co.za/index.php/2009/03/19/catch-all-queries/