博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

存储过程笔记

Posted on 2011-09-21 14:49  bug yang  阅读(145)  评论(0编辑  收藏  举报

1、使用游标

declare temp_cursor cursor for 

  select * from temp;

open temp_cursor;

fetch next from temp_cursor into @field;

while(@@Fetch_Staus=0)

begin

  insert into temp(id) values(@field);

  fetch next from temp_cursor into @field

end

Close temp_cursor
Deallocate temp_cursor



Select @@CURSOR_ROWS 可以得到当前游标中存在的数据行数。