select distinct * into #t
from aa
delete from aa
insert into aa
select *
from #t
drop table #t

解决方案 »

  1.   

    select distinct * into #tmp from aa 
    delete from aa
    insert into aa select * from #tmp
      

  2.   

    select A,B,C into #tmp from aa group by A,B,C
    drop table aa
    select * into aa from #tmp
    drop table #tmp
      

  3.   

    -- 查出唯一纪录生成临时表
    SELECT DISTINCT * INTO #tmp FROM aa
    -- 清空原表数据(数据量大建议用TRUNCATE TABLE,不写日志,速度快很多)
    TRUNCATE TABLE aa
    -- 导入处理后的数据
    INSERT INTO aa SELECT * FROM #tmp
      

  4.   

    select distinct * into #aa from 表truncate table 表
    insert into 表 select *from #aa
      

  5.   

    select * into #b from  #aa group by a,b,c having count(*)>1 --把不止一条的复制到别的表中delete from #aa where a in (
    select a from #aa group by a,b,c having count(*)>1) --只删除重复记录,不重复的不删除
    insert #aa --把重复,复制到原表中。
    select * from #b group by a,b,c having count(*)>1