Grant and Martin both have great answers and I echo everything they said.
To add on a bit, depending on how this is called you may consider not automatically adding the % wildcard and let the user signal what wildcards they need. That way if they truly need the wildcards, especially the one in front that makes the query non-SARGEable, they can have it, but they won't suffer the performance cost if they don't. If this is being called through SSMS and your users are SQL literate they can add the wildcards themselves. In a Gui it could be checkboxes.
Also, you can consider some of the CLR options that allow RegEx. I have not personally done performance testing, but I have been told they can be effecient and they definitely provide much more flexibility to get exactly the results you want.
↧