November 7, 2020 at 6:45 pm
Hi
I have a legacy application that uses a like %searchvalue% condition.
I have looked at using a computed column with reverse(column_like_is_used_on) which also has an index on the computed column.
The sql is then “select column from table where reverse_column like reverse(‘%searchstring’)
Which means the like is now “where reverse_column like ‘gnirtshcraes%’
This will use an index seek but the problem is for it to work I need to use substring or a left to get the rest of the start of the string for it to work and I get an index scan.
Really I want to get a fully qualified vale from the legacy app to use in the sql but it’s difficult to change it so any advice is appreciated thanks
November 8, 2020 at 7:10 pm
Thanks for posting your issue and hopefully someone will answer soon.
This is an automated bump to increase visibility of your question.
November 8, 2020 at 10:39 pm
This will use an index seek but the problem is for it to work I need to use substring or a left to get the rest of the start of the string for it to work and I get an index scan.
I guess I'm not understanding why you think you'd need to do that. Please post the code you're actually using. A table definition would help, as well.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply