From: moonsulu via SQLMonster.com on
Plamen Ratchev wrote:
>Correction:
>
>SET @keywords = REPLACE(@keywords, ' ', ' AND ');
>
>SELECT col1, col2
>FROM MyTable
>WHERE CONTAINS(*, @keywords);
>

Hi Plamen, thanks for your suggestion.

I tried your code but gave an error('syntax error occurred near...') if I
tried to input phrases with OR and AND

e.g.
head and shoulder
father and son
chicken or egg

I search the net but cant find any clue to resolve this.

--
Message posted via SQLMonster.com
http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server/200912/1

From: Plamen Ratchev on
I am not sure why you get errors. I just did a small test here and the following example works just fine (I am on SQL
Server 2008):

DECLARE @keywords NVARCHAR(30);

SET @keywords = N'brown fox';

SET @keywords = REPLACE(@keywords, ' ', ' AND ');

SELECT *
FROM FullTextTest
WHERE CONTAINS(*, @keywords);

--
Plamen Ratchev
http://www.SQLStudio.com
From: moonsulu via SQLMonster.com on
Plamen Ratchev wrote:
>I am not sure why you get errors. I just did a small test here and the following example works just fine (I am on SQL
>Server 2008):
>
>DECLARE @keywords NVARCHAR(30);
>
>SET @keywords = N'brown fox';
>
>SET @keywords = REPLACE(@keywords, ' ', ' AND ');
>
>SELECT *
>FROM FullTextTest
>WHERE CONTAINS(*, @keywords);
>


Hi Plamen,

Any words or phrases is ok except in phrases/keywords that have 'and' & 'or'.
For example, if I search for 'head or tail' it gives error.

--
Message posted via SQLMonster.com
http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server/200912/1

From: Plamen Ratchev on
Try to use double quotes for the keywords and see if it helps, like this:

DECLARE @keywords NVARCHAR(30);

SET @keywords = N'brown fox';

SET @keywords = '"' + REPLACE(@keywords, ' ', '" AND "') + '"';

The keywords string will become: '"brown" AND "fox"'.

--
Plamen Ratchev
http://www.SQLStudio.com
From: Geoff N. Hiten on
Could you post the web site? I always wanted a hosted system that someone
else paid for and maintains.

Look, someone is going to own this system via SQL Injection within a few
hours of it going live. I figure it might as well be me.

--
Geoff N. Hiten
Principal SQL Infrastructure Consultant
Microsoft SQL Server MVP

"moonsulu via SQLMonster.com" <u50488(a)uwe> wrote in message
news:a102acb7457fa(a)uwe...
> Plamen Ratchev wrote:
>>I am not sure why you get errors. I just did a small test here and the
>>following example works just fine (I am on SQL
>>Server 2008):
>>
>>DECLARE @keywords NVARCHAR(30);
>>
>>SET @keywords = N'brown fox';
>>
>>SET @keywords = REPLACE(@keywords, ' ', ' AND ');
>>
>>SELECT *
>>FROM FullTextTest
>>WHERE CONTAINS(*, @keywords);
>>
>
>
> Hi Plamen,
>
> Any words or phrases is ok except in phrases/keywords that have 'and' &
> 'or'.
> For example, if I search for 'head or tail' it gives error.
>
> --
> Message posted via SQLMonster.com
> http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server/200912/1
>

First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4 5
Prev: Joines Ralated
Next: SQL 2005 Query Response Time