40

I'm trying to build a facebook like search for my software.

I'd like to query the table customers.

I've set up a FULLTEXT Index and tried the next query

SELECT * FROM Customer where CONTAINS(*,'*ann*')

The query does return all the customers named Ann, but it doesn't return all the customers name Anne.

Is there a way to create prefix search on SQL Server 2008 using FTS?

bummi
  • 27,123
  • 14
  • 62
  • 101
Dig
  • 3,850
  • 3
  • 27
  • 33

1 Answers1

50

I've found a solution to my problem. The query should be:

select * from Customers where contains(*, '"ann*"')

The quotes are the important part.

Dig
  • 3,850
  • 3
  • 27
  • 33
  • 7
    Just wanted to add that this solution only works for prefixes like in `'"ann*"'`. It doesn't work for suffixes like in `'"*ann*"'` or `'"ann"'`. – Ricardo Nov 27 '13 at 16:20