Prev: Joines Ralated
Next: SQL 2005 Query Response Time
From: moonsulu via SQLMonster.com on 22 Dec 2009 04:24 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 22 Dec 2009 11:50 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 23 Dec 2009 04:16 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 23 Dec 2009 10:07 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 23 Dec 2009 10:52
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 > |