Hi,
I have used SQL FREETEXTTABLE to search in a table column based on the user entered words like a search engine and return best matching rows.
Table column will contain many questions and user will type something in textbox (in any order) and based on what he has typed I need to auto populate the search page.
I have used FREETEXTTABLE for it. But its not working in some cases.
What I have tried:
If I type 'what' it does not return anything.
DECLARE @query VARCHAR(50) = 'what'
SELECT TOP 10 Questions
FROM tblQuestion tq INNER JOIN FREETEXTTABLE(tblQuestion, Questions, @query) ft
ON ( tq.ID = ft.[Key] )
ORDER BY ft.Rank DESC
but if I type 'what is' it returns the 10 records.
DECLARE @query VARCHAR(50) = 'what is'
SELECT TOP 10 Questions
FROM tblQuestion tq INNER JOIN FREETEXTTABLE(tblQuestion, Questions, @query) ft
ON ( tq.ID = ft.[Key] )
ORDER BY ft.Rank DESC
I also tried CONTAINS and FREETEXT.
SELECT * FROM tblQuestion WHERE FREETEXT (Questions,'what')
Even this query returned zero rows.
But this below query returned few rows.
SELECT * FROM tblQuestion WHERE FREETEXT (Questions,'what is')
I want it to return even if there is single word typed by user.
Anyone knows the solution please help.
Thanks.