MS SQL Server 2005:table1具有全文索引。我想在一个查询中对它运行多个freetexttable搜索,但是这两次尝试都失败了。任何帮助将不胜感激,谢谢!附:我愿意升级到sql 2008,如果它解决了这个问题:)
CREATE FUNCTION fnt_FullTextSearch ( @s NVARCHAR(4000) )
RETURNS TABLE
AS
RETURN
( SELECT [key], [rank]
FROM FREETEXTTABLE(table1, *, @s) )
DECLARE @terms TABLE ( term VARCHAR(MAX) )
INSERT INTO @terms VALUES ( 'flu' )
INSERT INTO @terms VALUES ( 'acid' )
-- The inline function "..." cannot
-- take correlated parameters or subqueries
-- because it uses a full-text operator.
SELECT ft.[key], ft.[rank]
FROM @terms
CROSS APPLY fnt_FullTextSearch(term) ft
--syntax error on term
SELECT ft.[key], ft.[rank]
FROM @terms
CROSS APPLY FREETEXTTABLE(table1, *, term)
答案 0 :(得分:0)
也许是因为你在第二个语句中缺少别名?
SELECT FT.[key], FT.[rank]
FROM @terms
CROSS APPLY FREETEXTTABLE(table1, *, term) FT
这听起来微不足道......但我没有看到任何其他原因导致它失败!