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

Tip: Looking for answers? Try searching our database.

CONTAINS clause problem with single-quotes

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John Kotuby - 16 Dec 2007 20:45 GMT
Hi all,
This is cross posted to sqlserver.prgramming also...

I am confused by the MSDN help regarding the Contains clause for fulltext
search.
The Help states that the single-quote does not need to be escaped for
CONTAINS but must be escaped for FREETEXT.

Here is an example of a CONTAINS put together by my search program which
does not produce an error:

AND ( contains((summary),'("girl''s") and ("children''s" | "dog''s")')
OR contains((List_Name),'("girl''s") and ("children''s" | "dog''s")') )
order by list_Name

The fonts in my email are not correctly representing the clause. I have
replaced ' in the word girl's with 2 single quotes as in typical escaping
for strings...similar to a simple:
(Where list_name = 'girl''s'), because (Where list_name = 'girl's') of
course produces a syntax error.

The problem is that I expect only list_names that contain "girl's" to be
returned. However, with the CONTAINS clause using escape for single-quote
also returns any list_name that contains 'girl' as well.

When I don't double up the quotes, the CONTAINS clause returns an error "
syntax error near 's' ", not what is expected by the online Help.

Anybody have some help for me?
Russell Fields - 17 Dec 2007 14:32 GMT
John,

SQL Server fulltext indexes do not support searching for punctuation.  In
the string 'girl''s' the quote character is a word-breaker, so you wind up
with two words 'girl' and 's'.  In most cases 's' is a noise word and gets
dropped altogether.

If you are looking for punctuation, you will have to combine a full text
query clause with a string search clause such as:
   AND summary LIKE '%girl''s%'

RLF

> Hi all,
> This is cross posted to sqlserver.prgramming also...
[quoted text clipped - 25 lines]
>
> Anybody have some help for me?
John Kotuby - 17 Dec 2007 16:37 GMT
Thanks Russell,

That makes perfectly good sense. I appreciate the help.

Happy holidays.

> John,
>
[quoted text clipped - 38 lines]
>>
>> Anybody have some help for me?
 
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.