Honestly, I've gone over other questions posted here that mention conditional where clauses and I'm not seeing any answers that seem to work for my situation. If one does, please point me to it!
In a stored procedure called by an SSRS report, the user can select one of two values in a dropdown - say "Yes" or "No" and that goes into the variable @color
.
In the WHERE
clause of the sproc I need to filter differently depending on the user's selection.
So, if @color = 'Yes'
, then I need to have a line in the WHERE
clause that reads something like tb1.somecolumn = 'BLUE'
. But if @color = 'No'
then I don't need that line in the where clause at all (tb1.somecolumn
can be any value).
How do I conditionally include a line in the WHERE
clause?