select distinct * into #tmp from aa delete from aa insert into aa select * from #tmp
select A,B,C into #tmp from aa group by A,B,C drop table aa select * into aa from #tmp drop table #tmp
-- 查出唯一纪录生成临时表 SELECT DISTINCT * INTO #tmp FROM aa -- 清空原表数据(数据量大建议用TRUNCATE TABLE,不写日志,速度快很多) TRUNCATE TABLE aa -- 导入处理后的数据 INSERT INTO aa SELECT * FROM #tmp
select distinct * into #aa from 表truncate table 表 insert into 表 select *from #aa
select * into #b from #aa group by a,b,c having count(*)>1 --把不止一条的复制到别的表中delete from #aa where a in ( select a from #aa group by a,b,c having count(*)>1) --只删除重复记录,不重复的不删除 insert #aa --把重复,复制到原表中。 select * from #b group by a,b,c having count(*)>1
delete from aa
insert into aa select * from #tmp
drop table aa
select * into aa from #tmp
drop table #tmp
SELECT DISTINCT * INTO #tmp FROM aa
-- 清空原表数据(数据量大建议用TRUNCATE TABLE,不写日志,速度快很多)
TRUNCATE TABLE aa
-- 导入处理后的数据
INSERT INTO aa SELECT * FROM #tmp
insert into 表 select *from #aa
select a from #aa group by a,b,c having count(*)>1) --只删除重复记录,不重复的不删除
insert #aa --把重复,复制到原表中。
select * from #b group by a,b,c having count(*)>1