Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
DB Engine
SQL ServerMSDESQL Server CE
Services
Analysis (Data Mining)Analysis (OLAP)DTSIntegration ServicesNotification ServicesReporting Services
Programming
CLRConnectivitySQLXML
Other Technologies
ClusteringEnglish QueryFull-Text SearchReplicationService Broker
General
Data WarehousingPerformanceSecuritySetupSQL Server ToolsOther SQL Server Topics
DirectoryUser Groups
Related Topics
MS AccessOther DB ProductsMS Server Products.NET DevelopmentVB DevelopmentJava DevelopmentMore Topics ...

SQL Server Forum / Other Technologies / Full-Text Search / April 2006

Tip: Looking for answers? Try searching our database.

How to use CONTAINS to search words partially?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
redhotsly@hotmail.com - 21 Apr 2006 20:20 GMT
Hi,

Given the following table

Table : Computer
ID    Name             Notes
1     03-computer01    This webserver (ws) uses a SQL server
2     cls0001NTS5      Is connected to ws03sql001
3     ws03sql001
4     ws03sql002
5     ws03sql003
3     sql-ws03

and knowing that the Name and Note columns have been Indexed in a Full
Text Catalog.

How do I write a SELECT statement to return all the rows containing
"ws" AND "sql". With the data I've given, all the rows should be
returned.

This statement does not work because it seems like there is no way to
search inside the "words" of the index.

SELECT *
FROM computers
WHERE CONTAINS( Computer.*, '"ws" AND "sql"' )

I tried adding * before/after each words but it does not work.

Another solution would be to use a LIKE but it would have a serious
performance impact.

SELECT *
FROM computers
WHERE
    ( Computer.Name like ('%ws%' ) AND
      Computer.Name like ('%sqk%' ) ) OR
    ( Computer.Note like ('%ws%' ) AND
      Computer.Note like ('%sqk%' ) )

I cannot use the LIKE solution because in our case there are more
columns involved and it would be really slow.

Any help will be greatly appreciated.

Thank you

Sylvain
Hilary Cotter - 21 Apr 2006 20:45 GMT
You will have to add white space in your content before and after the tokens
for this to work. Otherwise this is the best way to do it.

Signature

Hilary Cotter
Director of Text Mining and Database Strategy
RelevantNOISE.Com - Dedicated to mining blogs for business intelligence.

This posting is my own and doesn't necessarily represent RelevantNoise's
positions, strategies or opinions.

Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html

Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com

> Hi,
>
[quoted text clipped - 44 lines]
>
> Sylvain
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.