• henrik staun poulsen (4/28/2009)


    Is SQL Server able to use indexes when using DateDiff(Day, D1, D2) = 0 ?

    Best regards

    Henrik Staun Poulsen

    FTFY 🙂

    The answer is yes.

    But only if:

    • There is an index on a persisted column in the table that is defined as datediff(day,d1,d2); or
    • There is an index on an indexed view column which resolves to datediff(day,d1,d2)

    Otherwise, no 😉

    Cheers,

    Paul