游标使用

declare cur1 cursor static for
select djid,grdm,dwdm,djrq,djbz from m_rcdj with(nolock) where isnull(cs,0)=0 order by grdm,dwdm,djrq

open cur1
fetch next from cur1 into @djid,@grdm,@dwdm,@djrq,@djbz ;

while @@fetch_status=0
begin

fetch next from cur1 into @djid,@grdm,@dwdm,@djrq,@djbz ;
end
close cur1
deallocate cur1

 

posted on 2015-04-16 18:10  zsfwh  阅读(130)  评论(0)    收藏  举报