I'm surprised to find that neither CONTAINS or CONTAINSTABLE seems to support syntax like the following where you pass a column name in for the last Search Condition parameter.
SELECT *
FROM dbo.Articles AS a
WHERE EXISTS
(
SELECT *
FROM dbo.Terms AS t
INNER JOIN CONTAINSTABLE(dbo.Articles, (ArticleBody), t.FulltextTerm)
AS ct ON ct.[Key] = a.ArticleId
)
The above query returns an "Incorrect syntax near 't'" error message.
The Terms table contains multiple rows with a FulltextTerm column, and if any of those FulltextTerm values is in the ArticleBody, it should be a match so that particular Article is selected. This is what I'm trying to achieve.
CONTAINS and CONTAINSTABLE appear to only support string literals or variables for the Search Condition parameter, which is very limiting. If that's the only option, it requires a lot more code and will certainly be much slower if I need to iterate thru the Terms table with a cursor or loop.
Am I missing a trick here, or any workarounds someone can suggest - preferably a set-based solution, i.e. avoiding loops.