all groups > sql server full text search > october 2007 >
You're in the

sql server full text search

group:

Allowing the omission of 'AND'


Allowing the omission of 'AND' Zark3
10/11/2007 1:35:13 AM
sql server full text search:
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
Re: Allowing the omission of 'AND' Russell Fields
10/11/2007 2:31:23 PM
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

[quoted text, click to view]

Re: Allowing the omission of 'AND' Simon Sabin
10/15/2007 10:56:13 PM
Hello Zark3,

You need to do it in your client code really.

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


[quoted text, click to view]

AddThis Social Bookmark Button