Escaping special characters in FTS. i.e:How to use double quotes within a phrase itself?


Recently, we got the following valid question:


I have something like :


 


SELECT line


FROM text1


WHERE CONTAINS(line, ‘”Good” Day”‘)


 


I get a Msg 7630 error because of the apostrophy in the middle of the phrase, but that is a part of my search phrase. So how can have a workaround to escape special characters in between phrase?


 


The solution is to use double quotes again to escape the double quotes within a phrase. This is an example:


 


SELECT line


FROM text1


WHERE CONTAINS(line, ‘” “”Good”” Day”‘)


 Any other special character will not raise any error as our parser won’t take it as phrase diferentiator, etc..


I hope this helps!


 

Comments (0)