all groups > sql server full text search > august 2005 >
You're in the

sql server full text search

group:

syntax error in CONTAINS query


syntax error in CONTAINS query DC Gringo
8/12/2005 4:43:10 PM
sql server full text search:
I have a CONTAINS search on a full-text index and I'm having trouble running
it on multiple terms without using an operator like AND or OR.

Here is my search query:

SELECT id
FROM table1
WHERE CONTAINS(column1,@keywords)


These work as they should:

declare @keywords varchar(25)
set @keywords = ' "word1 and word2" '

declare @keywords varchar(25)
set @keywords = ' "word1 or word2" '


....and this:

declare @keywords varchar(25)
set @keywords = ' "word1 word2" '

yields an error:

Syntax error occurred near 'failure'. Expected ''''' in search condition

Help!


_____
DC G


Re: syntax error in CONTAINS query John Kane
8/12/2005 7:43:44 PM
DC G,
You need to use the double quotes correctly... See KB article 246800
(Q246800) "INF: Correctly Parsing Quotation Marks in FTS Queries" at
http://support.microsoft.com//default.aspx?scid=kb;EN-US;246800 for FTS
query examples without an @variable...

I tried the following query using the pubs table pub_info with the
FT-enabled and populated column pr_info

declare @keywords varchar(25)
set @keywords = ' "word1 word2" '
SELECT pub_id, pr_info
from pub_info where contains(pr_info,@keywords)
/* -- expected results as word1 or word2 does not exist it this column
pub_id pr_info
------ -------------


(0 row(s) affected)
*/

I tested this on a Win2003 Server with SQL Server 2000 installed. Could you
post the full output of SELECT @@version as well as FT-enable the pubs
table pub_info and run a Full population and test the above query?

Thanks,
John
--
SQL Full Text Search Blog
http://spaces.msn.com/members/jtkane/



[quoted text, click to view]

Re: syntax error in CONTAINS query Hilary Cotter
8/12/2005 10:30:48 PM
I don't get this syntax error in SQL2000 or SQL2005. Which version are you
running?

--
Hilary Cotter
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
[quoted text, click to view]

AddThis Social Bookmark Button