I have a SP that gives me a lot of hard times.
The sp gets a two parameters @madeByUserId and @reportedByUserId. I want to have something like:
select
I think this will give you what you're after.
IF (@reportedByUser IS NULL) select * from table where MadeByUserId = @madeByUserId ELSE select * from table where MadeByUserId = @madeByUserId and ReportedByUserID = @reportedByUserID)