求救求救, 哪位能帮我看看这个存储过程哪里错了啊???
CREATE PROCEDURE T_Rank
@T_name VARCHAR(35)
AS
BEGIN
DECLARE @K VARCHAR(35),@W VARCHAR(5),@String VARCHAR(255)
DECLARE temptable CURSOR STATIC
FOR SELECT Keyword,Weight FROM Keyword WHERE Topic_name=@T_name
OPEN temptable
FETCH NEXT FROM temptable INTO @K,@W
SET @String=''
--Loop until no more row appear
WHILE ( @@FETCH_STATUS <>-1)
BEGIN
SET @String=@String+','+@K+' WEIGHT('+@W+')'
FETCH NEXT FROM temptable INTO @K,@W
END
CLOSE temptable
DEALLOCATE temptable
SET @String=(RIGHT(@String,len(@String)-1))
SET @String ='''ISABOUT('+@String +')'''
SELECT FT_TBL.ID, FT_TBL.Txt, KEY_TBL.Rank
FROM Post AS FT_TBL INNER JOIN CONTAINSTABLE ( Post, Txt, @String) AS KEY_TBL
ON FT_TBL.ID = KEY_TBL.[KEY]
ORDER BY KEY_TBL.Rank DESC
END
帮我改改这个储存过程,一直报错,谢谢了!!
------解决方案--------------------
CREATE PROCEDURE T_Rank
@T_name VARCHAR(35)
AS
BEGIN
DECLARE @K VARCHAR(35),@W VARCHAR(5),@String VARCHAR(255)
DECLARE temptable CURSOR STATIC
FOR SELECT Keyword,Weight FROM Keyword WHERE Topic_name=@T_name
OPEN temptable
FETCH NEXT FROM temptable INTO @K,@W
SET @String=''
--Loop until no more row appear
WHILE ( @@FETCH_STATUS <>-1)--一般使用@@FETCH_STATUS=0,因为还有-2的状态,所以<>-1不够精确
BEGIN
SET @String=@String+','+@K+' WEIGHT('+@W+')'
FETCH NEXT FROM temptable INTO @K,@W
END
CLOSE temptable
DEALLOCATE temptable
SET @String=(RIGHT(@String,len(@String)-1))
SET @String ='''ISABOUT('+@String +')'''--ISABOUT是自定义函数?还是你的是别的语言?
SELECT FT_TBL.ID, FT_TBL.Txt, KEY_TBL.Rank
FROM Post AS FT_TBL INNER JOIN CONTAINSTABLE ( Post, Txt, @String) AS KEY_TBL
ON FT_TBL.ID = KEY_TBL.[KEY]
ORDER BY KEY_TBL.Rank DESC
END