How do you escape double quotes inside a SQL fulltext 'contains' function?

后端 未结 2 419
生来不讨喜
生来不讨喜 2020-12-20 16:21

How do you escape a double quote character inside a MS SQL \'contains\' function?

SELECT decision
FROM table 
WHERE CONTAINS(decision, \'34\" AND wide\')
         


        
2条回答
  •  礼貌的吻别
    2020-12-20 16:59

    From documentation:

    Punctuation is ignored. Therefore, CONTAINS(testing, "computer failure") matches a row with the value, "Where is my computer? Failure to find it would be expensive."

    Since FULLTEXT does not even index the punctuation, you'll need to fine-filter your results using LIKE:

    SELECT  decision
    FROM    table 
    WHERE   CONTAINS(decision, '34 AND wide')
            AND decision LIKE '%34"%'
    

    This will preserve the benefits of fulltext.

提交回复
热议问题