it looks FREETEXTTABLE just allow searchkey parameter as variable, like this:
FROM FREETEXTTABLE(dbo.SampleTable, SampleColumn, @searchKey)
I have a list searchKey values, about 50000 records, how to "JOIN" searchKey table with FREETEXTTABLE
I've used WHILE but it's very slow
DECLARE @results as table(
Key NVARCHAR(100),
Rank INT
)
declare @numberOfRows INT = SELECT MAX(Id) FROM dbo.SearchKeyTable)
declare @step int = (SELECT MIN(Id) FROM dbo.SearchKeyTable)
WHILE (@step <= @numberOfRows)
BEGIN
declare @searchKey NVARCHAR(500) = (Select TOP(1) '''' + REPLACE([Description], '''', '"') + ''' OR ''' + REPLACE([itemname], '''', '"') + '''' From dbo.SearchKeyTable where id = @step ORDER BY Id)
insert into @results
select [Key] as KeyId, SUM([Rank]) as TotalRank FROM FREETEXTTABLE(dbo.SampleTable, SampleColumn, @searchKey) GROUP BY [Key]
SET @step = @step + 1
END
select * from @results
My dbo.SampleTable table is also large, about 16 millions record
Current solution: use c# multi-thread to replace WHILE