日期:2014-05-17 浏览次数:20362 次
create proc P_del
as
begin
delete from TEST where not ID in (select min(ID) from TEST group by 员工编号,打卡时间)
end
select * into #t from test a
where exists (select 1 from
(select 员工编号,打卡时间
from test
group by 员工编号,打卡时间
having count(1)>1) b where a.员工编号=b.员工编号 and a.打卡时间=b.打卡时间)
go
delete from test where id in (select id from #t)
go
insert into test
select min(id),员工编号,打卡时间
from #t
group by 员工编号,打卡时间
delete from TEST where exists(select 1 from TEST t where t.员工编号=TEST.员工编号 and t.打卡时间 =TEST.打卡时间 and t.ID<TEST.ID)