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

删除重复记录的问题
手头的数据库没有建主键,现在有大量的重复记录,用distinct导出数据依然提示错误。我新建的表建了联合主键,例如a字段和b字段组成联合主键。请问有没有比较好的办法删除重复记录啊?

------解决方案--------------------
--try


create table T(a int, b int)
insert T select 1, 1
insert T select 1, 1
insert T select 1, 1

insert T select 2, 2
insert T select 2, 2
insert T select 3, 1

insert T select 3, 3
insert T select 3, 3


select ID=identity(int, 1, 1), * into #T from T


delete #T
where ID not in(select max(ID) from #T group by a, b)

select * from #T
------解决方案--------------------
distinct导出数据依然提示错误
-------------------------------
提示什么错误呀?贴出来