How can I escape a bracket in a full-text SQL Server contains() query? I’ve tried all the following, none of which work:
CONTAINS(crev.RawText, 'arg[0]') CONTAINS(crev.RawText, 'arg[[0]]') CONTAINS(crev.RawText, 'arg\[0\]')
Using double quotes does work, but it forces the entire search to be a phrase, which is a showstopper for multiple word queries.
CONTAINS(crev.RawText, ''arg[0]'')
All I really want to do is escape the bracket, but I can’t seem to do that..
You don’t have to escape the [ as it has no special meaning in Full Text Search. If you do need to search for an exact match though, you can use ” marks.
Further, you can use multiple ” inside the single quotes:
This also works:
Anything put inside the double quotes is treated as exact text. Thus if I were to do a search of the Description field of the Production.ProductDescription table in AdventureWorks, I could use
and it would find matches for the word shifting that also had the phrase ‘on or off-road’.
The only special symbol is the ~, it can be used in place of the NEAR command.
is the same as
and will find matches where the words shifting and smooth are near each other.