Can I reset cursor's position to the beginning?

前端 未结 4 1990
感动是毒
感动是毒 2020-12-29 22:27

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:

4条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-29 23:22

    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;
    

提交回复
热议问题