我使用的是全文目录和功能CONTAINSTABLE
我的工作代码是:
SELECT * FROM CONTAINSTABLE(Genus, Name, '"Al*"')
因此,我创建了这样的自定义函数,它可以工作:
CREATE FUNCTION dbo.GetRank ()
RETURNS @tempRankTable TABLE([key] int, [rank] int)
WITH EXECUTE AS CALLER
AS
BEGIN
INSERT INTO @tempRankTable SELECT * FROM CONTAINSTABLE(Genus, Name, '"Al*"')
RETURN;
END
这也是工作代码:
CREATE FUNCTION dbo.GetRank (@table nvarchar(50), @column nvarchar(50), @searchString nvarchar(4000))
RETURNS @tempRankTable TABLE([key] int, [rank] int)
WITH EXECUTE AS CALLER
AS
BEGIN
INSERT INTO @tempRankTable SELECT * FROM CONTAINSTABLE(Genus, Name, @searchString)
RETURN;
END
有人知道如何将变量传递给CONTAINSTABLE以获取表名和列名吗?