Sql Server重复数据删除

时间:2014-12-11 13:53:22   收藏:0   阅读:217

--在sql2005下可以 ,sql2000不可以

 create  table tb(id int,name varchar(4))
insert tb select 1,‘aa‘
union all select 1,‘aa‘
union all select 2,‘bb‘
union all select 3,‘bb‘
union all select 4,‘cc‘
union all select 1,‘aa‘
union all select 4,‘cc‘


delete a from 
 (select id,name,rn=row_number() over(partition by id,name order by id) from tb) a where rn>1
select * from tb

原文:http://blog.csdn.net/hzvcan/article/details/4862927

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!