0

I have a really long filename stored in the database (the file name) with the full path: C:\folder\folder\my_supper_file_name_right_here.docx

If I use traditional

SELECT * FROM MYTABLE WHERE Name LIKE '%file%'

I will get all the results where the file name has in the name the word file

If I use

SELECT * FROM MYTABLE WHERE CONTAINS(Name, 'file')

I get nothing

The catalog is created, the index as well and is populated.

Is my CONTAINS query wrong?

user2818430
  • 5,853
  • 21
  • 82
  • 148
  • 2
    Full text search works with words. It's not a wildcard search, it's the same kind of search used in StackOverflow, Google, Bing. `C:\folder\folder\my_supper_file_name_right_here.docx` is a single item as far as full text search is concerned. – Panagiotis Kanavos Feb 28 '19 at 16:46
  • what about FREETEXT ? – user2818430 Feb 28 '19 at 16:55

1 Answers1

0

Using this way will solve your problem.

DECLARE @STR AS VARCHAR(100)

SET @STR = '"'+@STR +'*"'

SELECT * FROM MYTABLE WHERE (CONTAINS(Name, @STR))
Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77
  • 1
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jun 20 '22 at 11:24