How to place a condition in a filter criteria in t-sql?
Posted on 2016-11-21
I'm building a dynamic sql string and looking for the following.
Lets say there are two fields a text field (varchar 1000) and a date field.
Now I would like to filter for a date range in the date field, lets say between '1/1/16' and '2/1/16' but that should only be in case the text field contains a certain wording something like '%My Wording%'.
However in case the text field does not contain that word then I would want to see the record regardless of the date.
What is the simplest way to compose that?
(simple I mean in terms of clearness in reading, but at the same time should not compromise performance)