select a,b,min(field3) as field3,min(field4) as field4,.....min(fieldN) as fieldN into #temp
 from tablename group by a,b truncate table tablenameinsert into tablename select * from #tempdrop table #temp

解决方案 »

  1.   

    delete a where
    a.id <> (select top 1 id  from a d 
    where d.a = a.a and d.b = a.b order by a,c )
    可以达到要求
    ID为主键
      

  2.   

    select max(xmbh),xmmc,xmnr from t_sjzd 
    group by xmmc,xmnr having count(*)>1xmbh是关键字,xmmc和xmnr的组合会重复
      

  3.   

    select distinct a,b from yourtabletruncate table yourtableinsert into yourtable select * from ##tmptbdrop table ##tmpb
      

  4.   

    select distinct * into #temp from tablename
    go
    truncate table tablename
    go
    insert tablename select * from #temp
    go
    drop table #temp
    go
      

  5.   

    select distinct * into #table from table
    delete table
    select * into table from #table