zoukankan      html  css  js  c++  java
  • sql sever 常见游标写法,及如何强制停止

    declare @lot_msg varchar(255)      ,
          @ant int
    /*select  @lot_msg =predoccode from propurdadiplanhd        
    where  docdate>'2020-07-01'*/
          
     DECLARE cur1 CURSOR FOR select  predoccode from propurdadiplanhd        
    where  docdate>@datetime1

    OPEN cur1                                                                
      FETCH   NEXT  FROM cur1 INTO  @lot_msg    



       WHILE(@@FETCH_STATUS = 0 )                                                                
      BEGIN                   
         SET @ant = ISNULL(@ant,0) + 1          

    declare @lot Nvarchar(1000)  declare @begin_date  datetime      
    declare @time_date varchar(244)     
    set @lot= ' SELECT  top 1 @begin_Date=begin_Date FROM OPENQUERY(orc_link'+','  +''''+'select * from ps_schedule_head where lot_no=' +''''+'''' +@lot_msg+''''+''''+    
    ''''+')'       
    exec sp_executesql @lot ,N'@begin_date  datetime  output',    
    @begin_date output    
    print(@begin_date)  select   @time_date=   convert(datetime,replace(replace(replace(@begin_date,'年', '-'),'月','-'),'日',''))      
          
     update propurdadiplanitem  set      
     chengxinjindu =@time_date        
     from  propurdadiplanitem a inner join propurdadiplanhd  b on a.doccode =b.doccode 
     
     where isnull(chengxinjindu,'') !=''  and b.predoccode =@lot_msg 



    IF  @ant  >= 1000                  
      BEGIN                  
         BREAK                   
      END    
        FETCH   NEXT  FROM  cur1  INTO @lot_msg                  
      END                  
      CLOSE  cur1                  
      DEALLOCATE  cur1           

    红色部分为固定

    黑色部分为变更内容 

  • 相关阅读:
    小白自动化测试指南
    分布式性能测试框架用例方案设想(二)
    高QPS下的固定QPS模型
    测试自动化最佳实践【译】
    moco框架接口命中率统计实践
    基于docker的分布式性能测试框架功能验证(一)
    编写高质量代码:Web前端开发修炼之道(一)
    JavaScript中点操作符和中括号操作符区别
    Vue脚手架生成及配置
    Npm设置淘宝镜像
  • 原文地址:https://www.cnblogs.com/baili-luoyun/p/13358817.html
Copyright © 2011-2022 走看看