Perhaps I'm missing the obvious, but I've spent all day searching and searching with little luck for the answer to this problem. Perhaps I'm using the incorrect search terms? Never-the-less, this is what I'm trying to do.
I have a table with a FULL-TEXT Index set up on it. When I run the following, I am granted the expected results:
SELECT
A.*,
KEY_TBL.[Rank]
FROM
[dbo].[TableA] A
INNER JOIN
CONTAINSTABLE([dbo].[TableA], *, 'Jon OR Smith'
,5
) AS KEY_TBL
ON A.[Id] = KEY_TBL.[Key]
ORDER BY
KEY_TBL.[Rank] DESC
No problem there. What I want to do however, is pass 'Jon OR Smith' (or any other phrase searched by the end-user) into the query as an input parameter of a Stored Procedure. But when I try the following, I get no results:
declare @search_phrase VARCHAR;
set @search_phrase = 'Jon OR Smith'
SELECT
A.*
KEY_TBL.[Rank]
FROM
[dbo].[TableA] A
INNER JOIN
CONTAINSTABLE([dbo].[TableA], *, @search_phrase
,5
) AS KEY_TBL
ON A.[Id] = KEY_TBL.[Key]
ORDER BY
KEY_TBL.[Rank] DESC
I can't help but feel I'm missing the obvious here. I've tried doing SET @search_phrase = N'Jon OR Smith'
but that also yielded no results. In SSMS I get a message stating "Informational: The full-text search condition contained noise word(s)". Whilst I expect this due to OR being a stop word, I need the query to work (without affecting / turning off stop words). I can't help but feel that this should be something lots of people want to do / have already done and yet I've found no articles on it.
It should be noted that there may be one or more words within the search phrase, I will do the preprocessing before sending the completed search phrase to the Stored Procedure to add the necessary "OR"'s.
Can anyone point out where I'm going wrong please?