Select distinct * into #temp from table1
truncate table table1insert into table1
select #temp
drop table #temp

解决方案 »

  1.   

    select distinct * from other_table
      

  2.   


    select distinct * 
    into #a 
    from tablenam
    where username in 
    (select max(username) 
    from a
    group by username
    having (*)>1)delete a from a a,#a b where a.username=b.username and a.age=b.age insert into 
    a (usernaem,age)
    select username,age from #a 不知道你的字段名,所以你参考一下以上的语句
      

  3.   

    这样:while exists (select a,b,c,... from tablename group by a,b,c,... having count(*)>1)    --如果还有重复,继续删除
    begin
        set rowcount 1
        delete a 
        from tablename a,(select a,b,c,... from tablename group by a,b,c,... having count(*)>1) as b
        where a.a=b.a and a.b=b.b and ...
        set rowcount 0
    end
      

  4.   

    delete sf
    FROM TABLE1 k JOIN
          TABLE1 sf ON sf.id < k.id
    and  sf.we=k.we