如果我只传递一个字母作为参数
,则全文搜索无效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
如果只传递一个字母,我需要它只选择以该字母开头的句子。
答案 0 :(得分:1)
使用'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