Returning Rank with Full Text Search Contains Query

full-text-search, sql-server-2008

Solution

The rank function doesn't work with the CONTAINS query. You'll have to use CONTAINSTABLE to get the rank. See here.

Should look something like this:

SELECT Mas_text.*, k.rank
FROM Mas_text 
    INNER JOIN CONTAINSTABLE(Mas_text, text, 'Wanted and Engineers') k
    ON Mas_text.primarykey = k.[Key]

Problem

I have implemented Full Text Search on one of Sql Server 2008 Table. Query works fine when search some words using contains. I want to filter out the result on the basis of Rank functionality of Full Text Search. I am writing the following query ``` SELECT rank, * FROM Mas_text WHERE CONTAINS(text, 'Wanted and Engineers') ``` This query does not compile and give me error of "Invalid column name 'RANK'" Please suggest.

Original source