I need help with my query:
When I send to the query a parameter with the value -1, I would like to get all the records (this parameter wont filter the results), otherwise filter according the value.
I was trying something like this:
WHERE (StatusId = CASE WHEN @StatusId = - 1
THEN
@StatusId IS NULL
ELSE
StatusId = @StatusId END)
Thanks.