菜鸟求助!这个存储过程要怎么写
有考勤表表是这样的
工号 日期 打卡时间 有效
16759 2013-4-8 0:00:00 1900-1-1 9:00:00 0
9999 2013-4-8 0:00:00 1900-1-1 17:30:00 0
4577 2013-4-9 0:00:00 1900-1-1 9:00:00 0
4568 2013-4-9 0:00:00 1900-1-1 17:30:00 0
9966 2013-4-10 0:00:00 1900-1-1 9:00:00 0
8875 2013-4-10 0:00:00 1900-1-1 17:30:00 0
7736 2013-4-11 0:00:00 1900-1-1 9:00:00 0
8865 2013-4-11 0:00:00 1900-1-1 17:39:00 0
7774 2013-4-12 0:00:00 1900-1-1 8:29:00 0
4456 2013-4-12 0:00:00 1900-1-1 17:48:00 0
1125 2013-4-15 0:00:00 1900-1-1 8:33:00 0
现在要求每人每天在12点到12点30分只可以存在一张打卡记录,2张以上的把有效标识写为1.
这个只能用存储过程写,谢谢各位了
自己写了个但是各种错误
UPDATE K07
SET Flag =1
WHERE select * ,ROW_NUMBER() over(order by k0701) as rows from k07 WHERE
K0701 BETWEEN '1900-1-1 12:00:00' AND '1900-1-1 12:30:00'
and k0700>= @sdatebegin
and k0700<=@sdateend
AND rows !='1'
------解决方案--------------------create table tb(工号 int,日期 datetime ,打卡时间 datetime,有效 int)
insert into tb
select 16759,'2013-4-8 0:00:00','1900-1-1 9:00:00',0
union all select 9999,'2013-4-8 0:00:00','1900-1-1 17:30:00',0
union all select 4577,'2013-4-9 0:00:00','1900-1-1 9:00:00',0
union all select 4568,'2013-4-9 0:00:00','1900-1-1 17:30:00',0
union all select 9966,'2013-4-10 0:00:00','1900-1-1 9:00:00',0
union all select 8875,'2013-4-10 0:00:00','1900-1-1 17:30:00',0
union all select 7736,'2013-4-11 0:00:00','1900-1-1 9:00:00',0
union all select 8865,'2013-4-11 0:00:00','1900-1-1 17:39:00',0
union all select 7774,'2013-4-12 0:00:00','1900-1-1&