I would like to be able to alter a where clause in a Stored Procedure based upon the value of a parameter passed to it.
E.G.
This is how I think it should work but I cannot get it quite right
Declare @param as int
set @param = 1
Select Productname
from product
where
case @param = 1 then productname = 1
else productname <> 1
end
I have been looking at Dynamic SQL etc?
Thanks in advance