有谁帮我看一下这个存储过程吗,点执行一直处于执行状态!执行了半个小时还在执行
set ANSI_NULLS ONset 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