October 19, 2008 at 1:19 am
I created full text catalog & full text index in column Name,Description of table Product
when I write
1:
SELECT Name,Description
FROM dbo.Product
WHERE CONTAINS((Name,Description),'Funny OR romance')
--return 2 rows
but when using CONTAINS with variables
2:
DECLARE @Word1 varchar(15)
SET @Word1 = 'Funny'
DECLARE @Word2 varchar(15)
SET @Word2 = 'romance'
SELECT Name,Description
FROM dbo.Product
WHERE CONTAINS(*,'@Word1 OR @Word2')
--rerturn 0 row
-- I wonder false in snippet (*,'@Word1 Or @Word2')
if i write
3:
DECLARE @Word1 varchar(15)
SET @Word1 = 'Funny'
DECLARE @Word2 varchar(15)
SET @Word2 = 'romance'
SELECT Name,Description
FROM dbo.Product
WHERE CONTAINS(*,@Word1 OR @Word2)
-- no comply
help me correct the problem for program work same as 1(use variables)
thanks
October 20, 2008 at 9:15 am
Read the syntax of the CONTAINS clause in the Books Online (BOL): http://technet.microsoft.com/en-us/library/ms187787(SQL.90).aspx
If you use a variable all terms, including the "OR", in the query specification must be placed in the variable.
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply