它看起来像FREETEXTTABLE只允许searchkey参数作为变量,如下所示:
FROM FREETEXTTABLE(dbo.SampleTable, SampleColumn, @searchKey)
我有一个列表searchKey值,大约50000条记录,如何"加入"带有FREETEXTTABLE的searchKey表
我已经使用了WHILE,但它很慢
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
我的dbo.SampleTable表也很大,约有1600万条记录
答案 0 :(得分:0)
当前解决方案:使用c#多线程替换WHILE