Using SQL Server 2008. I have an input param in my stored proc called '@State'. The param can basically be '--All--' or can contain the state to filter.
So, if it is '--All--' I don't want to incorporate the @State into the where clause. Otherwise I'd like it to filter based on the provided @State. So basically it could result in this....
SELECT * FROM MyTable
WHERE Type='AAA' AND Status=@Status
or, if they pass '--All--'
SELECT * FROM MyTable
WHERE Type='AAA'
How can I do this in a stored proc?