数据库中删除重复记录的一种简单方法
假设存在如下数据表
create table Custom { CusNo int incremental, CusName nvarchar(50) }
现在想要删除其中CusName重复的记录,可以采用如下的sql语句:
delete Custom where CusNo not in (select max(CusNo) from Custom group by CusName)
假设存在如下数据表
create table Custom { CusNo int incremental, CusName nvarchar(50) }
现在想要删除其中CusName重复的记录,可以采用如下的sql语句:
delete Custom where CusNo not in (select max(CusNo) from Custom group by CusName)