0

I am attempting to do a fulltext search on a table where one of the rows is a log and contains characters such as ,.: and so on. Currently when a query is ran using the 'Contains' keyword which includes any of those characters no rows are returned. Is there any advice on the best route that can be take for this search? Here is what my current query look like at the moment:

ALTER Procedure [dbo].[searchLog]
    @searchValue varchar(150)
    AS
    Declare @myquote varchar(10)
    Declare @wildcard varchar(5)
    set @myquote ='"'
    set @wildcard ='*'
    set @searchValue = @myquote + @searchValue + @wildcard +@myquote    
    BEGIN
    SET NOCOUNT ON
    SELECT  o.ID, o.Name, o.DateRan, s.Name AS Job, o.Start, o.[End], o.Status, o.Logs
    FROM    dbo.o AS o LEFT OUTER JOIN
                dbo.j AS j ON o.Job = j.ID LEFT OUTER JOIN
                dbo.s AS s ON j.Script = s.ID
WHERE CONTAINS ((o.Name, o.Logs),  @searchValue)  
ORDER BY o.ID DESC

Example of Logs being searched:

"Sunday, July 7, 2019 1:20:00 PM
Seeking c:\xxxx\xxxx\log1_date.txt Seeking c:\xxxx\xxxx\log2_date.txt Seeking c:\xxxx\xxxx\log4_date.txt Monday, July 8, 2019 1:20:00 PM FTP AND PGP COMPLETED Processed 0 files ."

5
  • 1
    Can you show us an example log and example test search that does not give the desired result?
    – tttony
    Commented Jul 8, 2019 at 20:58
  • Generally, those are removed as noise words, have you edited your noise words list to include them? Commented Jul 8, 2019 at 20:59
  • @SeanGallardy I just updated the question with a sample. ill have to read up on editing noise words, but no i havent.
    – robdigm
    Commented Jul 8, 2019 at 21:03
  • @tttony I updated the question.
    – robdigm
    Commented Jul 8, 2019 at 21:03
  • @SeanGallardy there is no noise word lists that were created.
    – robdigm
    Commented Jul 8, 2019 at 21:14

1 Answer 1

0

You could try the CONTAINS function

SELECT * FROM [TableName] WHERE CONTAINS (*, 'Word')
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.