开发者

SQL server 2008 full text search not working with one letter

开发者 https://www.devze.com 2023-02-27 01:36 出处:网络
Full text search isn\'t working if I pass only o开发者_如何学编程ne letter as the param DECLARE @search_param NVARCHAR(250)

Full text search isn't working if I pass only o开发者_如何学编程ne letter as the param

DECLARE @search_param NVARCHAR(250)
SET @search_param = 'a'

    SELECT TOP 500
             [KEY] AS id,
             [RANK] AS relevance
    FROM     CONTAINSTABLE(table_name, column_name, @search_word)
    ORDER BY 2 DESC, 1 desc  

If only one letter is passed I need it to select only sentences that start with that letter.


Use 'a*' to search for "begins with a"

DECLARE @search_param NVARCHAR(250) SET @search_param = 'a'

-- if only one letter is passed
-- i need it to select only sentences that start with that letter
if len(@search_param) = 1 set @search_param = '"' + @search_param + '*"'

SELECT TOP 500
         [KEY] AS id,
         [RANK] AS relevance
FROM     CONTAINSTABLE(table_name, column_name, @search_param)
ORDER BY 2 DESC, 1 desc  
0

精彩评论

暂无评论...
验证码 换一张
取 消