或者先 alter table tb add id int identity(1,1) go delete a from tb a where exists(select 1 from tb where id<a.id and checksum(REPORTID,REPORTNAME,GROUPID)=checksum(a.REPORTID,a.REPORTNAME,a.GROUPID) go alter table tb drop column id go
alter table tb_name add ID int identity(1,1) go delete tb from tb_name tb where exists(select 1 from tb_name where REPORTID=tb.REPORTID and REPORTNAME=tb.REPORTNAME and GROUPID=tb.GROUPID and ID>tb.ID) go alter table tb_name drop column ID
alter table tb add id int identity(1,1)
go
delete a from tb a where exists(select 1 from tb where id<a.id and checksum(REPORTID,REPORTNAME,GROUPID)=checksum(a.REPORTID,a.REPORTNAME,a.GROUPID)
go
alter table tb drop column id
go
add ID int identity(1,1)
go
delete tb from tb_name tb where exists(select 1 from tb_name where REPORTID=tb.REPORTID and
REPORTNAME=tb.REPORTNAME and GROUPID=tb.GROUPID and ID>tb.ID)
go
alter table tb_name
drop column ID