当前位置: 代码迷 >> Sql Server >> 游标换成循环,多谢
  详细解决方案

游标换成循环,多谢

热度:38   发布时间:2016-04-24 19:57:29.0
游标换成循环,,,谢谢
  declare Level1 cursor for                                                  
  select companyid,dptid,dptname,capcode,oldcode,storplace_id,storplace,deptype,years,months,buydate,usedate,chief,chiefcode,examiner,paymethod,                                                  
         rowid,Capcode,Capname,round(orivalue/qty,2)  as price, qty,round(depvalue/qty,2) as depvalue,round(salvalue/qty,2) as salvalue,orivalue,depvalue,memo,usetype,        
         usercode,username                                  
  from VfCapdocA with (nolock)                                                  
  where doccode=@doccode                                
                                  
                                  
  select @CardNo=0                      
                                                    
  open Level1       
                                             
  fetch next from Level1 into @companyid,@dptid,@dptname,@capcode,@oldcode,@storplace_id,@storplace,@deptype,@years,@months,@buydate,@docdate,@chief,@chiefcode,@examiner,                                                  
                              @paymethod,@rowid,@Capcode,@Capname,@price,@digit,@depvalue,@salvalue,@allorivalue,@alldepvalue,@memo,@usetype,@usercode,@username                                                  
  while @@fetch_status=0                                                  
  begin                                                  
     set @i=1                                                  
                          
     while @i<=@digit                                                  
     begin                                                  
  相关解决方案