1、
select distinct * into #t from 表
truncate table 表
insert into 表 select * from #t
drop table #t2、
select * from 表 where 字段 not like '%XX%'
select distinct * into #t from 表
truncate table 表
insert into 表 select * from #t
drop table #t2、
select * from 表 where 字段 not like '%XX%'
--简单的方法就是借用临时表
--方式:把数据首先放到临时表
--在临时表中处理重复记录问题.
--删除物理数据表
--从临时表把数据取出来,放入物理表中
--删除临时表
Select distinct * into #temp from table1delete table1insert into table1
Select * from #temp drop table #temp方法2:
--方式2:
delete 表名
from 表名 tt
where exists(select 1 from 表名 where 字段=tt.字段 and 字段=tt.字段 and 主键<tt.主键)
方法3
--保留最小的ID
delete 表 where ID not in(select min(ID) from 表 group by 字段...(注:重复的字段行))