I currently have the following select statement, but I wish to move to full text search on the Keywords column. How would I re-write this to use CONTAINS?
SELECT MediaID, 50 AS Weighting
FROM Media m JOIN @words w ON m.Keywords LIKE '%' + w.Word + '%'
@words is a table variable filled with words I wish to look for:
DECLARE @words TABLE(Word NVARCHAR(512) NOT NULL);
If CONTAINS allows a variable or column, you could have used something like this.
However, according to Books Online for SQL Server CONTAINS, it is not supported. Therefore, no there is no way to do it.
Ref: (column_name appears only in the first param to CONTAINS)
If you are not against using a temp table, and EXEC (and I realize that is a big if), you could do the following:
This would generate a query like:
And results like this: