I have a stored procedure that compares a date in the database to two dates entered by the user. If the date in the database is between those two dates the result should show.
I need is to fix the query below so that
1. priority_start is left empty and priority_end is left empty then return all results. The problem here is fields that are null, those should be returned as well.
2. User enters both fields start and end, then the results should show the matching records MINUS the null records
Query:
AND ( a.PrioDate BETWEEN @priority_start AND @priority_end ) or a.PrioDate is null