首页 > 代码库 > 张羿给的删除重复数据的mssql语句

张羿给的删除重复数据的mssql语句

select count(1), gsdm, id
from ods_sc.T_D_DEVICE_COMMON
group by gsdm, id
having count(1) > 1;

delete from ods_sc.T_D_DEVICE_COMMON
where rowid in
(select a.rowid
from ods_sc.T_D_DEVICE_COMMON a, ods_sc.T_D_DEVICE_COMMON b
where a.gsdm = b.gsdm
and a.id = b.id
and a.rowid < b.rowid);
commit;

可以在测试环境试试这个语句。

张羿给的删除重复数据的mssql语句