Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to specify multiple criteria using Contain cls

Author  Topic 

larryg003
Starting Member

18 Posts

Posted - 2010-06-17 : 09:37:00
How do you use the contain clause to specify multiple
conditions:

i.e
select
count(distinct UNIQUE_STORY_INDEX)
from dbo.news_sample
where contains(RELATED_RICS, "'BAC'")
and not contains(HEADLINE_SUBTYPE, '"5"')

the above statement didn't work (error message)

Any ideas?

I can't use the "like" format because i need to run a full-text query.

Devart
Posting Yak Master

102 Posts

Posted - 2010-06-18 : 07:00:20
Normally, such statement shouldn't produce an error. But in you sample you have misplaced quotes in contains(RELATED_RICS, "'BAC'") expression.
The correct expression is
contains(RELATED_RICS, '"BAC"')
May be this is the reason of error.

In order to make CONTAINS function work similar to LIKE add * symbols around you substring.
E.g.
contains(RELATED_RICS, '"*BAC*"')

Devart,
Database tools for SQL Server
http://www.devart.com/dbforge/sql
Go to Top of Page
   

- Advertisement -