如何删除sqlserver中某条重复的数据?

第一步:首先查询出重复的数据

select  重复列名,count(重复列) from tablename  group by 重复列 having count(1)>1

第二部:根据重复列的id删除重复列中id小的一条


delete  from   tablename WHERE    id in (select min(id) from   tablename group   by   重复列 having   count(1)>1 )

猜你喜欢

转载自blog.csdn.net/qq_33285345/article/details/86636669