let's say I have a table with columns ID, Date1 and Date2 where Date2can be NULL. I now want to have an SQL statement that ignores Date2 if it is NULL.
So I need something like that:
SELECT *
FROM
[myTable]
WHERE
ID = @someId
AND Date1 <= GETDATE()
AND Date2 >= GETDATE() IF Date2 IS NOT NULL
So I want to check if Date2 is not NULL and then compare it with the current date. If it is NULL then I just want to ignore it.
Hope my request is clear and understandable.
Cheers
Simon