I am trying to turn this query into something more SARGable (mainly the LEN(CardNumber.....) bit), any ideas? (This is only part of the query). CardNumber
is Varchar(50)
and already has a index
on it
SELECT ContactGUID, CardNumber,
ROW_NUMBER() OVER(PARTITION BY ContactGUID ORDER BY SignedDate DESC) as row_no
FROM Cards
WHERE CardNumber LIKE '633176%'
AND LEN(CardNumber) IN (16, 19) AND (Status IS NULL OR Status = 'A')
AND ContactGUID IS NOT NULL
Any help/advice much appreciated.
Thanks