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