How to do it:
select * from myTable WHERE [myIDcolumn] = @recID or (@recID is null and [myIDcolumn] is null)
If @recID is null , the first part will never be true, but the second part will be if [myIDcolumn] is null , which covers the case of null . If @recID not null , the first part will match when necessary (and the second part will be ignored). Thus, both cases are covered.
Tj crowder
source share