Syntax error near 'of' in the full-text se

2019-03-14 09:23发布

I have the following WHERE clause:

WHERE (@Keywords IS NULL
            OR (CONTAINS((p.Title, p.Area, p.[Message]), @Keywords))
        )

If @Keywords = 'control', then the query executes successfully and filters my records

If @Keywords = 'control of', then I get the following error:

Syntax error near 'of' in the full-text search condition 'control of'.

Why is this and what can I do to resolve the issue?

The main reason I'm using this method over using LIKE condition is so that I can search multiple words.

1条回答
一纸荒年 Trace。
2楼-- · 2019-03-14 10:05

Enclose the keywords in double quotes if you want to search exactly for control of

SET @Keywords = '"control of"'

If you want to search for control and of, use the following:

SET @Keywords = 'control AND of'

But server may consider of as a garbage or stop word, so in this case use the following:

SET @Keywords = 'control AND "of"'
查看更多
登录 后发表回答