Use multiple words in FullText Search input string

后端 未结 1 1559
滥情空心
滥情空心 2020-12-08 20:26

I have basic stored procedure that performs a full text search against 3 columns in a table by passing in a @Keyword parameter. It works fine with one word but

相关标签:
1条回答
  • 2020-12-08 21:01

    You will have to do some pre-processing on your @Keyword parameter before passing it into the SQL statement. SQL expects that keyword searches will be separated by boolean logic or surrounded in quotes. So, if you are searching for the phrase, it will have to be in quotes:

    SET @Keyword = '"this is a search item"'
    

    If you want to search for all the words then you'll need something like

    SET @Keyword = '"this" AND "is" AND "a" AND "search" AND "item"'
    

    For more information, see the T-SQL CONTAINS syntax, looking in particular at the Examples section.

    As an additional note, be sure to replace the double-quote character (with a space) so you don't mess up your full-text query. See this question for details on how to do that: SQL Server Full Text Search Escape Characters?

    0 讨论(0)
提交回复
热议问题