最近问重复记录的怎么这么多?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

解决方案 »

  1.   

    select distinct * from 表  ---行重复
      

  2.   

    给你一个例子:
    如果重复记录要随机取一条出来:处理如下: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 组合分组
      

  3.   

    是不是有什么病毒搞的大家的SQL总是产生重复记录?
    我的几个客户的SQL SERVER都有重复的记录
    最后没办法只好把脚本给他们发过去!