You have to parse your query so that it looks like this:
select * from John where contains(*,'("cat" AND "dog" AND "horse") AND NOT
( "cow" AND "bull")')
I have upper cased the boolean operators for clarity.
For your date query it would look like this
select * from John where contains(*,'("cat" AND "dog" AND "horse") AND NOT
( "cow" AND "bull")')
where orderdate>'2007-01-01'
You cannot search on a date string and hope for it to be interpreted as a
date and do inequality operations on it. So I could not do something like
this
select * from John where contains(*,'("cat" AND "dog" AND "horse") AND NOT
( "cow" AND "bull") and OrderDate>'2007-01-01')
as sql FTS can only interpret the date string as a string and only do not
equal or equal operations against it.

Signature
RelevantNoise.com - dedicated to mining blogs for business intelligence.
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
> Hello everyone,
>
[quoted text clipped - 28 lines]
>
> Thanks to all...
ML - 09 Nov 2007 13:52 GMT
FYI - the original thread can be found here
http://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.sqlserver.
programming&mid=b965bf2b-ce05-4ad2-baee-47205465946b
As I understand it, he OP was trying to find out how to combine a negative
FTI search (using CONTAINS) with additional restrictions in the WHERE caluse.
I suggested building the condition using NOT(CONTAINS()).
ML
---
Matija Lah, SQL Server MVP
http://milambda.blogspot.com/
Hilary Cotter - 09 Nov 2007 15:38 GMT
thanks ML - that is an interesting approach. That should work, but it would
be expensive if the results set was large.

Signature
RelevantNoise.com - dedicated to mining blogs for business intelligence.
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
> FYI - the original thread can be found here:
> http://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.sqlserver.
programming&mid=b965bf2b-ce05-4ad2-baee-47205465946b
[quoted text clipped - 9 lines]
> Matija Lah, SQL Server MVP
> http://milambda.blogspot.com/
John Kotuby - 09 Nov 2007 14:16 GMT
Thanks Hilary...
I guess I confused the issue by mentioning the Date comparison in my post.
The crux of the matter was whether I could use JUST exclusions in the
Contains clause. For example...
contains((description),'(!"cow" &! "bull")')
The idea being that any record is acceptable, as long as the 'description'
field does NOT contain either "cow" OR "bull"
In your syntax I guess that would translate into
contains((description), 'NOT ( "cow" AND "bull")').
Someone in the SQLServer.Programming group suggested:
where NOT(contains((description),'"cow" OR "bull"'))
and <the rest of the conditions>
That seems to work well, and now I use it whenever the program sees that
there were no keywords entered into any of the text boxes for each of the
conditions "With ALL of the Words:" or "With at Least ONE of the Words:",
and the user has placed entries only in "With NONE of the Words:".
My code now becomes (when only exclusions are entered):
Where NOT (contains((description),'("cow" | "bull")') OR
contains((long_name),'("cow" | "bull")') )
AND ( list_date > '10/01/2007')
Note here that the date comparison is completely separated from the Contains
clause, as you have indicated.
However, I have noticed that you use the * in your contains example, whereas
I am creating a "contains" for each Full Text Indexed field being queried.
Does this mean I can consolidate the query I am using with * instead of
querying each field separately? In my Text Catalog, only the 2 fields
"description" and "long_name" are indexed.
Thanks again...
> You have to parse your query so that it looks like this:
>
[quoted text clipped - 52 lines]
>>
>> Thanks to all...
Hilary Cotter - 09 Nov 2007 15:35 GMT
No, you can't do this. Basically this is like saying, search on every word
in the dictionary and return hits to every document and then subtract the
ones which contain cow or bull.

Signature
RelevantNoise.com - dedicated to mining blogs for business intelligence.
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
> Thanks Hilary...
>
[quoted text clipped - 98 lines]
>>>
>>> Thanks to all...
John Kotuby - 09 Nov 2007 18:48 GMT
Thanks Hilary,
But just a little clarification please...
When you say
"No, you can't do this. "
Did you mean my code example as suggested by ML (and which is currently
written and operating in test mode)?
Or were you refering to my question of using the * in the syntax.
Sorry to bother you again, but I will be putting the code into production
soon...
> No, you can't do this. Basically this is like saying, search on every word
> in the dictionary and return hits to every document and then subtract the
[quoted text clipped - 103 lines]
>>>>
>>>> Thanks to all...
Hilary Cotter - 12 Nov 2007 15:54 GMT
No, MLs code should work. I was referring the the wildcard usage.

Signature
RelevantNoise.com - dedicated to mining blogs for business intelligence.
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
> Thanks Hilary,
>
[quoted text clipped - 121 lines]
>>>>>
>>>>> Thanks to all...