sqlserver 2005怎样删除数据表中重复的数据

2024-12-28 21:11:47
推荐回答(3个)
回答1:

用select Top 1 选择到临时表,清空当前表,再重新初始化自增因子,然后写回!

回答2:

select 标识列1....等所有你想保存的列 from table1 into tempTable
group by 标识列1..等所有你想保存的列
having count (标识列)>1
--ID除外

delete from table1 where 标识列 in (select 标识列 from tempTable)

insert into table1 (所有列) select 所有列 from tempTable Group by 所有列

回答3:

select distinct * into 新表 from 表
delete from 表
insert into 表 select * from 新表
drop table 新表