Question : Multiple word Search statement

Hello, I'm using the following in an attmpt to seach one or all of four columns for a word or words. Similar to a google search. It works for a single word but does not for multiple words. SQL 2005

How can my statement be modified to work with multile words???

My sql server is on a hosted site where I cannot use contains...
Code Snippet:
1:
2:
3:
4:
5:
6:
SELECT * FROM mm_articles
where (rtrim(@SearchString)  is NUll or rtrim(Title)  like rtrim('%' + @SearchString) + '%')
or (rtrim(@SearchString)  is NUll or rtrim(SubTitle)  like rtrim(@SearchString) + '%')
or (rtrim(@SearchString)  is NUll or rtrim(Intro)  like rtrim('%' + (@SearchString) + '%'))
or (rtrim(@SearchString)  is NUll or rtrim(body)  like rtrim(@SearchString) + '%')
and Active = 'Yes'
Open in New Window Select All

Answer : Multiple word Search statement

Assuming that Split function is correct for your data (without seeing it, I can only guess) than do it as follows:

Declare @SearchString varchar(500)                              -- Modify data type as necessary.
Set @SearchString = LTRIM(RTRIM(@SearchString))

Declare @Search Table (SearchString varchar(50))

Insert      @Search(SearchString)
Select      '%' + SearchString + '%'
From      dbo.Split(@SearchString, ' ')

SELECT      *
FROM      mm_articles a
            Left Join @Search s On a.Title Like s.SearchString
                                          Or a.SubTitle Like s.SearchString
                                          Or Intro Like s.SearchString
                                          Or Body Like s.SearchString
and Active = 'Yes'
Random Solutions  
 
programming4us programming4us