I need to search in a table that has a text field (named Description) with special characters: ñ, á, ó…
Ex: Description = “La canción tiene buen ritmo!!!”
I can search for ‘cancion’ or ‘canción’ and this row need to be returned.
So, I did:
- A function that replace this special chars.
-
A select that use it to search in the table:
SELECT IdItem, Description FROM tblItemsTable WHERE dbo.fnReplaceSpecialChars ( Description ) LIKE '% word%' OR dbo.fnReplaceSpecialChars ( Description ) LIKE 'word%'
My problem is this search is very slow…
Can it be done in a better/optimize way?
Thanks!
You can use an accent insensitive collation (name contains
AI) to avoid having to use your functionBoth use of leading wild cards and an explicit collate clause mean that an index could not be used so probably won’t help much if at all on the speed front. You may want to look into setting up a full text index for this.
You would need to build the Full Text catalogue
WITH ACCENT_SENSITIVITY =OFF