I would like to find all rows that would match the predicate MyColumn LIKE '%FooBar'
but by by using an index seek rather than a scan.
One approach is essentially to create a reversed version of MyColumn and search for the reversed pattern (ooF%
) on that column with a conventional index on the reversed column.
I do not like manually creating this reversed column, however. Oracle has the concept of reversed key indexes that can automatically index on REVERSE(MyColumn)
without the need for manually materializing reversed versions of the column (either in form of a physical column on the table or by creating an indexed view).
Are there any other ways to perform suffix substring searches in SQL Server efficiently?