I am creating a SQL query in which I need a conditional where clause.
where
It should be something like this:
SELECT DateAppr, Time
This seemed easier to think about where either of two parameters could be passed into a stored procedure. It seems to work:
SELECT * FROM x WHERE CONDITION1 AND ((@pol IS NOT NULL AND x.PolicyNo = @pol) OR (@st IS NOT NULL AND x.State = @st)) AND OTHERCONDITIONS