本文介绍了我可以重置光标的位置到开始吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如主题。我可以简单地将光标的位置重置到Transact-SQL的开头,以便它可以再次在表上运行吗?我想在以下上下文中重置它: $ b $bÚ
As in the topic. Can I simply reset cursor's position to the beginning in Transact-SQL, so it can run again over the table? I want to reset it in the following context:
DECLARE @userID INT DECLARE user_cursor CURSOR FOR SELECT userID FROM users WHILE /* some condition */ BEGIN ... FETCH NEXT FROM user_cursor INTO @userID IF @@FETCH_STATUS = 0 BEGIN /*... here goes the reset of the cursor ...*/ END ... END/ p>
thanx for any advice.
推荐答案您需要将光标声明为滚动,如下所示
you need to declare your cursor as scroll, like this
declare c scroll cursor for (select statement);然后在任何时候找到第一个只需使用以下
then at any time for locating to the first just use the following
fetch first from c;更多推荐
我可以重置光标的位置到开始吗?
发布评论