1

I have double quotes in my Keyword. How can I search this in my fulltext search query. I have this query

SELECT  top 10 K.[KEY], 10, K.[RANK]
FROM    CONTAINSTABLE(ProductKeywords, Keywords, '("19*") AND ( "<Cat>5" OR "<Cat>30" OR "<Cat>398" ) AND NOT "<Blocked>"' ) AS k

It works fine but when i have double quotes in my keyword like

SELECT  top 10 K.[KEY], 10, K.[RANK]
FROM    CONTAINSTABLE(ProductKeywords, Keywords, '("19"*") AND ( "<Cat>5" OR "<Cat>30" OR "<Cat>398" ) AND NOT "<Blocked>"' ) AS k

it gives this error

Msg 7630, Level 15, State 3, Line 1
Syntax error near '*' in the full-text search condition '("19"*") AND ( "<Cat>5" OR "<Cat>30" OR "<Cat>398" ) AND NOT "<Blocked>"'.
4

2 回答 2

1

要转义双引号,只需将它们加倍,例如

SELECT * FROM Tbl WHERE Contains(name, '""quoted""')
于 2016-04-11T13:59:34.100 回答
0

如何在 SQL 全文“包含”函数中转义双引号?

SELECT TOP 10
    K.[KEY]
  , 10
  , K.[RANK]
FROM
    CONTAINSTABLE(ProductKeywords, Keywords, '("19*") AND ( "<Cat>5" OR "<Cat>30" OR "<Cat>398" ) AND NOT "<Blocked>"')
    AND Keywords LIKE '19"%'
    AS k
于 2014-08-29T14:09:01.127 回答