What is the best way to include an input param in the WHERE clause but exclude it if it is null?
WHERE
There are a number of ways I believe, but I can\'t seem
You can use IsNull
where some_column = IsNull(@yourvariable, 'valueifnull')
EDIT:
What you described in the comment can be done like:
where (@code is null or code = @code)
Here's another approach
SELECT * FROM Thingies WHERE ( @thingId IS NULL OR ThingID = @thingId )