Let's say my full text search query is below:
USE AdventureWorks2012;
GO
SELECT Name
FROM Production.Product
WHERE CONTAINS(Name, '"chain*" OR "full*"');
GO
I need one more column that shows which condition was matched in the CONTAINS
clause.
SELECT Name ,Matched_condition
FROM Production.Product
WHERE CONTAINS(Name, '"chain*" OR "full*"');
+---------------------+-------------------+
| name | matched_condition |
+---------------------+-------------------+
| chain smokers | chain |
+---------------------+-------------------+
| full throttle | full |
+---------------------+-------------------+
| chain full of smoke | chain,full |
+---------------------+-------------------+
What should I use to get the new column (matched_condition
)?
I have a list of conditions that includes 200 words.
Best Answer
Possible realization. Fulltext search replaced with common LIKE substring search.
Source table:
Patterns table (can be temporary or table-type variable):
The query:
Query result:
fiddle