主题:Transact-SQL如何实现两个记录集两个循环
[color=FF0000]两个循环中判断@@FETCH_STATUS = 0好像是相互影响的。不能实现我想要到结果[/color]
DECLARE @webID bigint
DECLARE @webAddress varchar(500)
DECLARE @content varchar(8000)
DECLARE @contentLen int
DECLARE @OrderID int
DECLARE @MatchNum int --匹配的个数
-----分析搜索词-------------------------
DECLARE @SearchKeyNum int --搜索词的个数
DECLARE @p int --分析搜索词字符串的前指针
DECLARE @q int --分析搜索词字符串的后指针
DECLARE @searchKeyLen int --搜索词的长度
DECLARE @searchKey varchar(100) --分割后单个搜索词
DECLARE @KeyRight numeric(10,2)--某个关键词加权值
DECLARE @SearchKeyOrderID int--某个搜索词排序值
DECLARE @i int --循环次数
SET NOCOUNT ON
SELECT webID,webAddrees,content FROM webPageInfo WHERE isnew=0
DECLARE SearchIndex CURSOR FOR
SELECT webID,webAddrees,content FROM webPageInfo WHERE isnew=0
OPEN SearchIndex
FETCH NEXT FROM SearchIndex INTO @webID, @webAddress,@content
select @@FETCH_STATUS as FETCH_STATUS,@i as i,@content
------数据库搜索一遍------------
set @i=0
WHILE @@FETCH_STATUS = 0
BEGIN
set @i=@i+1
FETCH NEXT FROM SearchIndex INTO @webID, @webAddress,@content
select @@FETCH_STATUS as FETCH_STATUS,@i as i,@content
--处理多个搜索词的全文匹配情况
DECLARE SearchKey CURSOR FOR
SELECT SearchKey,SearchKeyOrderID FROM SearchKey_table
OPEN SearchKey
FETCH NEXT FROM SearchKey INTO @SearchKey ,@SearchKeyOrderID
set @i=0
WHILE @@FETCH_STATUS = 0
BEGIN
FETCH NEXT FROM SearchKey INTO @SearchKey ,@SearchKeyOrderID
set @i=@i+1
END
CLOSE SearchKey
DEALLOCATE SearchKey
END
CLOSE SearchIndex
DEALLOCATE SearchIndex
GO
DECLARE @webID bigint
DECLARE @webAddress varchar(500)
DECLARE @content varchar(8000)
DECLARE @contentLen int
DECLARE @OrderID int
DECLARE @MatchNum int --匹配的个数
-----分析搜索词-------------------------
DECLARE @SearchKeyNum int --搜索词的个数
DECLARE @p int --分析搜索词字符串的前指针
DECLARE @q int --分析搜索词字符串的后指针
DECLARE @searchKeyLen int --搜索词的长度
DECLARE @searchKey varchar(100) --分割后单个搜索词
DECLARE @KeyRight numeric(10,2)--某个关键词加权值
DECLARE @SearchKeyOrderID int--某个搜索词排序值
DECLARE @i int --循环次数
SET NOCOUNT ON
SELECT webID,webAddrees,content FROM webPageInfo WHERE isnew=0
DECLARE SearchIndex CURSOR FOR
SELECT webID,webAddrees,content FROM webPageInfo WHERE isnew=0
OPEN SearchIndex
FETCH NEXT FROM SearchIndex INTO @webID, @webAddress,@content
select @@FETCH_STATUS as FETCH_STATUS,@i as i,@content
------数据库搜索一遍------------
set @i=0
WHILE @@FETCH_STATUS = 0
BEGIN
set @i=@i+1
FETCH NEXT FROM SearchIndex INTO @webID, @webAddress,@content
select @@FETCH_STATUS as FETCH_STATUS,@i as i,@content
--处理多个搜索词的全文匹配情况
DECLARE SearchKey CURSOR FOR
SELECT SearchKey,SearchKeyOrderID FROM SearchKey_table
OPEN SearchKey
FETCH NEXT FROM SearchKey INTO @SearchKey ,@SearchKeyOrderID
set @i=0
WHILE @@FETCH_STATUS = 0
BEGIN
FETCH NEXT FROM SearchKey INTO @SearchKey ,@SearchKeyOrderID
set @i=@i+1
END
CLOSE SearchKey
DEALLOCATE SearchKey
END
CLOSE SearchIndex
DEALLOCATE SearchIndex
GO