Domanda

I have this query in SQL Server 2008

SELECT TOP 1000 * 
FROM Quotes 
INNER JOIN QuoteImages ON Quotes.Id = QuoteImages.QuoteId 
WHERE FREETEXT(QuoteText,'some text')

How can I order the results by most relevant or highest rank ?

I have read the msdn documentation, but it seems complicated and I don't know how to create complex stored procedures.

È stato utile?

Soluzione

You should use FREETEXTTABLE (link) instead of FREETEXT:

SELECT TOP 1000 Q.*, QI.*
FROM Quotes Q
INNER JOIN QuoteImages QI
    ON Q.Id = QI.QuoteId 
INNER JOIN FREETEXTTABLE(Quotes,QuoteText,'some text') FT
    ON Q.Id = FT.[Key]
ORDER BY RANK DESC
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top