I'm trying to write something like :
SELECT *
FROM MyTable m
WHERE m.Category = CASE WHEN @Category IS NULL THEN m.Category ELSE @Category END
Basically, I need lines where m.Category equals @Category if this one has a value ; else, I need all lines.
BUT if m.Category has NULL value, the line is NOT send back because SQL needs something lile WHERE m.Category IS NULL and not WHERE m.Category = NULL.
So, how could I modify my request to tell to SQL : "I need ALL lines if @Category is null (even lines where m.Category is null), but if @Category has a value, I just need lines where m.Category matches @Category ?