Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Full Text Search - Contains

Author  Topic 

schadaway
Starting Member

1 Post

Posted - 2008-09-30 : 13:18:48
Hi,

First time post so hi everyone.

I'm working with full text searches on 2005 and everything has been working fine. However, I have a situation where people can save their search phrases in a table. Then when a new searched post is created, that post is checked against the previously saved phrases for a match.

I thought it would be a simple case of using the contains keyword with the column holding the saved phrases. So for example:

CONTAINS(TBL1.FullTextColumn, TBL2.SearchPhrase)

but it would seem that the contains keyword can't take a column name as the second argument only a string literal or variable.

So firstly, can anyone confirm that this is the case, and if it is would anyone out there have any ideas on how I could get around this issue?

I hope I have explained myself clearly there and fingers crossed someone can help me out.

Thanks in advance

Steve

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2008-09-30 : 17:30:07
Hello Steve,
- yes, CONTAINS can't take a column as the contains_search_condition.
- but variable is possible

Idea:
declare @SearchPhrase nvarchar(max) -- max or whatever (depending on TBL2.SearchPhrase)
select @SearchPhrase=SearchPhrase from TBL2 where ...

CONTAINS(TBL1.FullTextColumn, @SearchPhrase)

Greetings
Webfred


Planning replaces chance by mistake
Go to Top of Page
   

- Advertisement -