标题:有谁帮我看一下这个存储过程吗,点执行一直处于执行状态!执行了半个小时还 ...
取消只看楼主
hong293
Rank: 1
等 级:新手上路
帖 子:9
专家分:5
注 册:2012-7-16
结帖率:0
已结贴  问题点数:20 回复次数:3 
有谁帮我看一下这个存储过程吗,点执行一直处于执行状态!执行了半个小时还在执行
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
   
--调整考勤   
ALTER  procedure [dbo].[Proc_UpdateKq]   
@Yearmonth as varchar(7)   
as     
  Declare @FirstDate as smallDatetime      --月初第一天   
  Declare @employeeid as int          --员工ID   
  Declare @RestType as int            --假日类别   
  Declare @checkDate as smalldatetime --考勤日期   
/*   
RestType --假日类型   
OnOffDutyData --考勤档案表   
RestType=6--1-5有一天为 6   
RestType=5--周6更新为5   
*/   
   set @FirstDate=@Yearmonth +'-01'   
   
   Declare Cur Cursor for      
      select Employeeid,checkDate from OnOffDutyData  where Datediff(month,CheckDate,@FirstDate)=0 and RestType=6 and (Datepart(dw,checkdate) between 2 and 6) and employeeid in (select employeeid from employeemsg where department in (select departmentid from datadepartment where preCode='CY')) order by Employeeid,checkDate   
   Open Cur   
     fetch next from cur into @employeeid,@checkDate   
     While (@@Fetch_Status=0)      
       begin      
               
             update OnOffDutyData set  RestType=5,classsouce=3 where employeeid=@employeeid and Datepart(dw,checkdate)=7 and isnull(RestType,0)=0 and (Datepart(wk,checkdate)=Datepart(wk,@checkdate))     
   
                  
       fetch next from cur into @employeeid,@checkDate   
   end            
   
 Close cur        
       Deallocate cur   
   


 



   

搜索更多相关主题的帖子: procedure 考勤 
2012-07-16 11:48
hong293
Rank: 1
等 级:新手上路
帖 子:9
专家分:5
注 册:2012-7-16
得分:0 
求解啊   
2012-07-16 12:25
hong293
Rank: 1
等 级:新手上路
帖 子:9
专家分:5
注 册:2012-7-16
得分:0 
回复 2楼 hong293
你一段没什么问题,执行出来有二千多条记录!
2012-07-18 10:57
hong293
Rank: 1
等 级:新手上路
帖 子:9
专家分:5
注 册:2012-7-16
得分:0 
回复 3楼 qingshuiliu
谢谢你的指导哦,我在  

 set @FirstDate=@Yearmonth +'-01'   后面插入一个select Employeeid,checkDate from OnOffDutyData  where Datediff(month,CheckDate,@FirstDate)=0 and RestType=6 and (Datepart(dw,checkdate) between 2 and 6) and employeeid in (select employeeid from employeemsg where department in (select departmentid from datadepartment where preCode='CY')) order by Employeeid,checkDate   
到临时表去,执行之后可以了呵呵
2012-07-18 11:09



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-373492-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.331439 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved