I have a SQL procedure with two parameters @DateFrom
and @DateTo
and SQL query inside.
For example
select *
from Produc p
where p.ProductType = 1
and (ProductCategory = 5 or ProductCatalogId = 3)
or (p.StartDate between @DateFrom and @DateTo)
But I want a last or only when parameters @DateFrom
and @DateTo
are not null.
Try:
Although I'm wondering if thats the logic you are looking for, maybe the following is what you actually want.