转:SQL重复记录查询

select distinct *  into #Temp from RepeatAll
drop table RepeatAll
select * into RepeatAll from #Temp
drop table #Temp

select identity(int,1,1) id,* into #Temp from RepeatAll
drop table RepeatAll
--select
select name,sex,address from #Temp group by name,sex,address having (count(*)>1)
--delete
delete from #Temp where id not in
(select min(id) id from #Temp group by name,sex,address)
select name,sex,address into RepeatAll from #Temp
drop table #Temp

posted on 2011-03-09 10:55  catvi  阅读(191)  评论(0编辑  收藏  举报

导航