I have a table with a column as nvarchar(max) with text extracted from word documents in it. How can I create a select query that I’ll pass another a list of keywords as parameter and return the rows ordered by the number of matches?
Maybe it is possible with full text search?
Yes, possible with full text search, and likely the best answer. For a straight T-SQL solution, you could use a split function and join, e.g. assuming a table of numbers called dbo.Numbers (you may need to decide on a different upper limit):
And a splitting function that uses that table of numbers:
Then you can simply say:
As a procedure:
Then you can just pass in
@List(e.g.EXEC dbo.Search @List = N'foo,bar,splunge') from C#.This won’t be super fast, but I’m sure it will be quicker than pulling all the data out into C# and double-nested loop it manually.