方法1: --简单的方法就是借用临时表 --方式:把数据首先放到临时表 --在临时表中处理重复记录问题. --删除物理数据表 --从临时表把数据取出来,放入物理表中 --删除临时表 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 de
方法3 --保留最小的ID delete 表 where ID not in(select min(ID) from 表 group by 字段...(注:重复的字段行))
select distinct * into #t from tablename delete tablename insert tablename select * from #t drop table #t
大家看看这个方法可行吗??create table temp as (select distinct * from stu_infor)truncate table stu_inforinsert into stu_infor select * from temp
--简单的方法就是借用临时表
--方式:把数据首先放到临时表
--在临时表中处理重复记录问题.
--删除物理数据表
--从临时表把数据取出来,放入物理表中
--删除临时表
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
de
--保留最小的ID
delete 表 where ID not in(select min(ID) from 表 group by 字段...(注:重复的字段行))
delete tablename
insert tablename select * from #t
drop table #t