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
 General SQL Server Forums
 New to SQL Server Programming
 text search

Author  Topic 

craigmacca
Posting Yak Master

142 Posts

Posted - 2012-01-19 : 10:31:32
Hi i need a SP that will return results in relevence order, i want to pass in a string of words, not sure what the best approch is sould i have a function that will split the string into a table and search against that?

DELCARE @SearchTerm NVARCHAR(2048)
SET @SearchTerm = 'test content to test'

SELECT *
FROM content c
WHERE c.content_title like '%' + @SearchTerm + '%'

X002548
Not Just a Number

15586 Posts

Posted - 2012-01-19 : 10:54:53
you want to search for each word in the string?


Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

craigmacca
Posting Yak Master

142 Posts

Posted - 2012-01-19 : 11:24:48
Thanks, i was asking if this was the best way to do this? I need for a web search so it will need to be a quick query.

i can loop through and search each word but is is the best way?
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2012-01-19 : 16:38:32
probably not

IF you can use a function

SELECT * FROM Table a JOIN dbo.function b ON a.Col LIKE '%'+b.Col+'%'

The function would be a table function to retun you rows based on yoyr string


Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page
   

- Advertisement -