Sql server 删除重复记录的SQL语句
其他方法: ----A:保留id最大的行,删除其它行--方法1
delete from t
inner join(select name,max(id) as> on t.name = a.name and t.id a.id
--方法2
delete from t
where exists(select * from where name = t.name and> ----B:保留id最小的行,删除其它行
--方法1
delete from t
inner join(select name,min(id) as> on t.name = a.name and t.id a.id
--方法2
delete from t
where exists(select * from where name = t.name and> ----C:删除所有重复的name行,一行也不留
delete from t
inner join
(select> on t.id = b.id
Robert.H.fu
页:
[1]