![]() |
#2
hong2932012-07-16 12:25
|
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