当前位置: 代码迷 >> Sql Server >> , 哪位能帮小弟我看看这个存储过程错哪了啊
  详细解决方案

, 哪位能帮小弟我看看这个存储过程错哪了啊

热度:71   发布时间:2016-04-27 10:45:14.0
求救求救, 哪位能帮我看看这个存储过程哪里错了啊???
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 [email protected]_name
 OPEN temptable
 FETCH NEXT FROM temptable INTO @K,@W
 SET @String=''  
 --Loop until no more row appear
 WHILE ( @@FETCH_STATUS <>-1)
 BEGIN
  SET @[email protected]+',[email protected]+' WEIGHT([email protected]+')' 
  FETCH NEXT FROM temptable INTO @K,@W
 END
 
 CLOSE temptable
 DEALLOCATE temptable
 SET @String=(RIGHT(@String,len(@String)-1))
 SET @String ='''ISABOUT([email protected] +')'''

 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 [email protected]_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 @[email protected]+',[email protected]+' WEIGHT([email protected]+')'
FETCH NEXT FROM temptable INTO @K,@W
END
 
CLOSE temptable
DEALLOCATE temptable
SET @String=(RIGHT(@String,len(@String)-1))
SET @String ='''ISABOUT([email protected] +')'''--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
 
  相关解决方案