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 / October 2007

Tip: Looking for answers? Try searching our database.

Allowing the omission of 'AND'

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Zark3 - 11 Oct 2007 09:35 GMT
Hi all,
Probably a complete FAQ/newbie question, but i'm not finding it (or
searching wrongly).
Suppose my user wants to do a search for two words, they want to do an
AND-search and they don't want to type in AND. i.e. 'John Smith'
should be 'John AND Smith' for CONTAINSTABLE to return any results,
but the user will type in 'John Smith' and expect to see both 'John
Smith' and 'Smith, John' (so no exact string matching, only AND-
connected search).
Is there a standard way to tell CONTAINSTABLE that it should connect
all separate words with AND?
TIA,
Chris
Russell Fields - 11 Oct 2007 19:31 GMT
Chris,

Well, providing there are no extra complexitities in the value they can
type, you can handle adding the AND yourself.  One shorthand that may work
is to do this prior to issuing the query prepare the string by:

set @string = REPLACE(REPLACE(REPLACE(Replace(ltrim(rtrim(@string)),
    ' ',' '),' ',' '),' ',' '), ' ', ' AND ')

RLF

> Hi all,
> Probably a complete FAQ/newbie question, but i'm not finding it (or
[quoted text clipped - 9 lines]
> TIA,
> Chris
Simon Sabin - 15 Oct 2007 23:56 GMT
Hello Zark3,

You need to do it in your client code really.

Simon Sabin
SQL Server MVP
http://sqlblogcasts.com/blogs/simons

> Hi all,
> Probably a complete FAQ/newbie question, but i'm not finding it (or
[quoted text clipped - 9 lines]
> TIA,
> Chris
 
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.