如何查找游标的记录数 [英] How to find a cursor's records count
本文介绍了如何查找游标的记录数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的光标
this is my cursor
declare @product1 CURSOR
SET @product1 = CURSOR for SELECT Id from Tbl_StkDetailedBookStock where IsActive='True'
and BookStockId=@tempd4 ;
here I have 2 records in cursor (SELECT Id from Tbl_StkDetailedBookStock where IsActive = 'True' and BookStockId = 11)
那么如何找到光标数= 2,因为我想要找到光标数并根据该数量进行一些操作。
任何人都可以帮忙找到这个。
谢谢。
So how to find cursor count = 2 because I want find the cursor count and do some operation based on that count.
anybody help to find this.
thanks.
推荐答案
检查这个
http://social.msdn.microsoft.com/Forums/en-US/transactsql/thread/7d9f2a34-382f-4546-a82f-e3b97bc35bd5 [ ^ ]
试试这个,
Hi,
try this,
declare @product1 CURSOR
declare @ID int
declare @cnt int;
set @cnt = 0;
SET @product1 = CURSOR for SELECT Id from Tbl_StkDetailedBookStock where IsActive=''True''
and BookStockId=@tempd4 ;
open @product1
fetch next from @product into @ID
while(@@fetch_status=0)
begin
set @cnt=@cnt+1
fetch next from @product into @ID
end
close @product1
deallocate @product1
select @cnt
希望它能帮助....
快乐编码.. :)
hope it will help....
Happy coding.. :)
这篇关于如何查找游标的记录数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文