--如果没有自增列,增加自增列
ALTER TABLE #b ADD id INT IDENTITY(1,1)
--查出重复数据并删除
select *
--delete
from #b
where 项目编码 in (select 项目编码 from #b group by 项目编码 having count(*) > 1)
and id not in (select min(id) from #b group by 项目编码 having count(*)>1)
--如果没有自增列,增加自增列
ALTER TABLE #b ADD id INT IDENTITY(1,1)
--查出重复数据并删除
select *
--delete
from #b
where 项目编码 in (select 项目编码 from #b group by 项目编码 having count(*) > 1)
and id not in (select min(id) from #b group by 项目编码 having count(*)>1)