Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to do a full-text search in SQL Server 2005, ordering on the number of matches?

For example, let's say I have the following products for sale.

Tennis Racquets
Tennis Balls
Hockey Sticks

If I do a search like:

select * from products where freetext(productname,'tennis ball')

The first three results would be returned as they all have "tennis" or "ball". I would like to order the results so that "tennis balls", the one with two matches instead of one, is on top.

Is there a "match ratio" column, or something that can be used to rank how close the match was? Is there a better way to do a full-text search that would allow for ranking?

share|improve this question
up vote 3 down vote accepted

You could try FREETEXTTABLE:

SELECT ft.[Rank], p.*
FROM dbo.products AS p 
INNER JOIN FREETEXTTABLE(products, productname, 'tennis ball') AS ft  
ON ft.key_column = p.key_column  
ORDER BY ft.[Rank] DESC;
share|improve this answer
That is exactly what I'm looking for. Thank you! – dangowans Aug 13 '12 at 17:05

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.