日期:2014-05-18  浏览次数:20435 次

在线等待,重复数据筛选
表1中有个字段   M   ,怎样把重复的记录删除啊!

------解决方案--------------------
--假设有唯一字段ID

delete 表名
where id not in (select min(id) from 表名 group by M)

------解决方案--------------------
如果只有一个字段:

select distinct * into #temp from 表

truncate table 表

insert into 表 select * from #temp

drop table #temp

------解决方案--------------------
同意楼上的看法!
如果不只一个字段!

delete a from table a where exists(select 1 from table1 b a.m=b.m and a.id> b.id)