What is the most optimized solution for this situation:
WHERE clause of my query is like this:
WHERE columnX LIKE @Account + '%'
I use ‘%’ because @Account could be ‘ ‘ and in that case I want to get all values. In all other cases I could use equals (=).
This solution is not optimized because I have index on columnX and I would like to use equals (=) because of that. Also, solution with OR is not acceptable because of performance.
Do you have some other recommendation? I tried with CASE in WHERE clause, but didn’t find good solution that is optimized. Our compatibility level is 80, so cannot use newer syntax. (don’t ask why 🙂 )
TnX in advance!
Nemanja
you can try this