Field1相同的就删除么?要不要留下一条?

解决方案 »

  1.   

    如果Field2不重复:
    delete a from 表 a where exists(select 1 from 表 where Field1=a.Field1 and Field2<a.Field2) 否则:
    select identity(int,1,1) as id,* into #t from 表truncate table 表insert into 表 
    select Field1,Field2 from #T a 
    where not exists(select 1 from #T where Field1=a.Field1 and id<a.id) drop table #T
      

  2.   

    insert into # select distinct * from t 
    insert into t select * from #
    drop table 3
      

  3.   

    楼主的表述有问题,1.是要删除全部重复数据还是只留一条?
    2.2个字段完全相等算重复数据还是只要Field1重复就算重复数据?
    如果是2的后者保留那条记录?
      

  4.   

    delete from table where field1 = (select distinct field1 from table)
      

  5.   

    说明一下:只要Field1重复就算重复数据
      

  6.   

    delete from 表
    where field1 in (select field1 from 表
                      group by field1
                      having count(1)>1)