ALTER PROCEDURE [dbo].[Hr_addNewMonth]
as
BEGIN
INSERT INTO [Hr_1]
([日期时间],[姓名]
,[考勤号码])
select distinct CONVERT(char(10),日期时间,120) as atime,姓名,考勤号码 from Hr a
where (select COUNT(*) from [Hr_1] b where b.考勤号码 = a.考勤号码 and b.日期时间 = CONVERT(char(10),a.日期时间,120) ) < 1
order by a.姓名,CONVERT(char(10),a.日期时间,120)
END
原文:http://www.cnblogs.com/szlixin/p/4335451.html