SQL语句删除重复数据

1.如表中没有主键,先添加自动增长主键

alter table 表名 add 列名 int identity (1,1) primary key

2.删除重复数据

delete from 表名 where id not in
(select min(id) from 表名 group by id)

------id1为新增自增的列,id为原来没有自增的id列

delete from DeceasedInformation where id1 not in
(select MIN(id) from DeceasedInformation group by id)

 

posted @ 2016-03-27 22:56  黄者之风  阅读(1367)  评论(0编辑  收藏  举报