You can try to do something like this:
select * from foo where (@parameter1 is null AND @parameter2 is null) OR (@parameter1 = 'value1' AND @parameter2 = 'value2')
In any case, it needs some tweaking in your own request, but now you will check if the parameters are null or the initial conditions where-where are satisfied.
Jan_V source share