您的位置:首页 > 博客中心 > 数据库 >

Sql Server重复数据删除

时间:2022-03-14 03:42

--在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

热门排行

今日推荐

热门手游