Eran
Eran

Reputation: 11

Using Full-Text Search instead of "Like '%____%' query

I am quering a table (about 150,000 rows and growing) with a big varchar field (size 2000) which can't be indexed (and there's no point even if it could be). I am using Sql Server 2008. The query I used till now was:

select * from tbl_name where field_name like '%bla bla%'

("bla bla" is according to what the user searched for)

In order to improve performence, I wann'a start using the Full-Text Search feature (already defined a catalog and a text index on this field). I am a bit confused from what I read about quering with this option. what query should I use in order to get exactly the same results as the query I used to use before?

Thanks! Eran.

Upvotes: 1

Views: 2106

Answers (1)

aks
aks

Reputation: 25377

CONTAINS() will get you the LIKE() functionality you are seeking with one exception - I noticed in the comments that you also want to match the second entry - "hhhEranttt". Unfortunately, due to the lack of suffix search this is currently not possible.

For the other entries you can run a prefix search - CONTAINS(field_name, '"eran*"') which matches all the other entries since full-text searches are case-insensitive.

HTH.

Upvotes: 2

Related Questions