Say I want to get all the people with the surname Smith
SELECT *
FROM Person
WHERE LastName = 'Smith'
The above is fine. However, as my Database Collation is CS, a LastName
value like SmItH
, smith
or SMITH
will not be included in the results above.
I could do
SELECT *
FROM Person
WHERE UPPER(LastName) = 'SMITH'
Which would work, however the query isn't then SARGable. However, the rub is that this will cause a table / index scan rather than a seek.
I know I can change the column or database collation but is there a way I can make the query SARGable without making any database changes?