最近问重复记录的怎么这么多?select distinct * into #a from TB
gropu by col1,col2....
having count(*)>1
delete TB from TB a,#a b where a.id=b.id
insert into TB (COL1,col2...)
SELECT col1,col2..... from #a
gropu by col1,col2....
having count(*)>1
delete TB from TB a,#a b where a.id=b.id
insert into TB (COL1,col2...)
SELECT col1,col2..... from #a
如果重复记录要随机取一条出来:处理如下:select col1,col2,
,(select top 1 c from T3 where col1 = d.col1 and col2 = d.col2 order by newid()) as c
from T3 d
group by col1,col2 --col1,col2 组合分组
我的几个客户的SQL SERVER都有重复的记录
最后没办法只好把脚本给他们发过去!