I am trying to create a sql server query select. I have one argument that can be null or not. WHen the @value is null I would like to return all mycolumns with the null value. If value is not null I want to return mycolumns with that value.
How best to handle this, i tried:
SELECT name FROM mytable
WHERE coalesce( @value,mycolumn)=mycolumn
I got a feeling it lies in the handling of the null value. How can I resolve?