I have a list of words/phrases in a table phrases
. I have another table with a full-text catalog indexing the description
column.
I want to populate a table results
with a record for each phrase, and the number of times that phrases was found in the description:
INSERT INTO results(phrase, foundcount)
SELECT phrase,
(SELECT COUNT(*) FROM table WHERE CONTAINS(table.description, phrase))
FROM phrases;
No matter how I try, this results in the error:
Incorrect syntax near `phrase`. Expecting STRING, TEX_LEX, or VARIABLE
I would really rather not use a cursor just so I can assign each phrase
to a variable. Is that really the only option?
Best Answer
Try this: