p.campbell
p.campbell

Reputation: 100587

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?

Upvotes: 0

Views: 1392

Answers (1)

ypercubeᵀᴹ
ypercubeᵀᴹ

Reputation: 115560

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

Upvotes: 2

Related Questions