I am using the following where predicate to get only Monday to Fridays tickets from one of our DW tables.
SET DATEFIRST 1
SELECT TicketID
FROM Tickets AS T
WHERE DATEPART(DW,T.StartDate) BETWEEN 1 AND 5 ....`
Would it be possible to let me know if the DATEPART
predicate is sargable please?
I took a look at the actual execution plan and it uses an index seek even with the DATEPART
function.
We have already optimised many of our old queries by modifying the where predicates, analysing the plan, set statistics io on, etc. For this one I am not sure if there is a better way to get tickets only from mon - fri (shifts..)?