views:

923

answers:

3

I thought full-text search would let me do exact phrase searching in a more optimized way than a LIKE predicate, but I'm reading that it doesn't do that exactly.

Is "LIKE" the most efficient way to search thousands of rows of TEXT fields in a table for a literal string?

It's got to be exact matching...

A: 

Apparently, CONTAINS is faster than a LIKE query...

http://www.docstoc.com/docs/2280727/Microsoft-SQL-Server-70-Full-Text-Search-What-is-full-text-search

(Profiling can be found on Page 19 of that presentation)

John Rasch
A: 

What version of SQL Server are you on? I would recommend replacing TEXT with VARCHAR(MAX), if you ever can (SQL Server 2005 and up).

What makes you say that full text won't work? How have you set up fulltext, and what do your fulltext queries look like?

Marc

marc_s
I set up full-text by using SQL Server Management studio and creating a full-text catalog with a full-text index on a field in one of my tables.My query: SELECT TOP 10 serial_no,writer_id,writing,assignment_type,subdate,titleFROM write_onsite WHERE CONTAINS(writing'"take it once"')
Caveatrob
- the query returns things that have take in the beginning, any number of words in betwee, then the word "once". I just want the literal phrase "take it once"
Caveatrob
Still not clear: what VERSION of SQL Server?
marc_s
A: 

LIKE(string%) will work faster if you have proper index on the column and you are looking for "string" only in the beginning of the value. You have to use LIKE(%string%) if the "string" might be in the middle of your value; table scan will be fired in this case and it's slow (slower than full-text search mostly). You can use the CONTAINS() function of full-text search for exact match.

Irina C