▲使用伪列去掉同一个表中的重复数据
delete tb_temp a
where a.rowid<>(select max(rowid) from tb_temp b
where a.phone_no=b.phone_no);

解决方案 »

  1.   

    例:SQL> select * from tb_temp;A     B
    ----- -----
    1     Zhang
    2     Wang
    3     Li
    2     Wang
    1     ZhangSQL> 
    SQL> delete tb_temp A
      2  where A.rowid<>(select max(rowid) from tb_temp B
      3  where A.a=B.a and A.b=B.b);2 行 已删除SQL> select * from tb_temp;A     B
    ----- -----
    3     Li
    2     Wang
    1     Zhang
      

  2.   

    以下语句适用于,主键字段属性没有标识增量。
    select * into #tmpp from youtable 
    insert into youtable select top 1 * from #tmpp
    drop table #tmpp
      

  3.   

    以下语句适用于,主键字段属性没有标识增量。
    select * into #tmpp from youtable where id=8888
    delete youtable where id=8888
    insert into youtable select top 1 * from #tmpp
    drop table #tmpp
      

  4.   

    create table tablea_bak 
    as 
    select distinct(a.*) from tableA a 然后drop以前那个表
    最后rename tableA_bak to tableA最好在不用这张表的时候。