34,588
社区成员
发帖
与我相关
我的任务
分享
--楼主:能不能先把你那“相同”的标准说明白啊?\
--表中:记录的哪些字段相同时,就视为相同(重复)行呢?
--没个标准,你叫人家怎么回答啊?
declare @tb table(id int identity,StartDate datetime)
insert @tb select
'2009-09-10' union all select
'2009-09-10' union all select
'2009-09-14'
delete @tb
from @tb t
where exists(select * from @tb where StartDate=t.StartDate and id>t.id)
select * from @tb
id StartDate
----------- -----------------------
2 2009-09-10 00:00:00.000
3 2009-09-14 00:00:00.000
(2 行受影响)