Searching a full-text indexed column for pipe characters
Consider a column names MyCol
with a full-text index. We want to find those rows that have a value of |foo|
.
Tried this, but doesn't find those with exactly |foo|
:
SELECT * FROM MyTable WHERE CONTAINS(MyCol,'开发者_开发百科"|foo|"')
It returns anything with foo
. It seems as if pipes are disregarded as separators.
How can I escape, or otherwise ensure that the exact string |foo|
is found?
Escape with:
SELECT * FROM MyTable WHERE CONTAINS(MyCol,'[|]foo[|]')
I think this works too:
SELECT * FROM MyTable WHERE CONTAINS(MyCol,'||foo||') ESCAPE '|'
Oops, this is full-text search. According to this question/answer, there is no way!:
sql-server-full-text-search-escape-characters
精彩评论