declare @max integer,@id integer
declare cur_rows cursor local for select 主字段,count(*)
From 表名
group by 主字段 having count(*) > 1
o
PEn cur_rows
fetch cur_rows into @id,@max
while @@fetch_
status=0
be
gin select @max = @max -1
set
rowcount @max
delete f
rom 表名 where 主字段 = @id
fetch cur_rows into @id,@max
end
close cur_rows
set rowcount 0
select distinct * into
#tmp from tableName
drop table tableName
select * into tableName from #Tmp
drop table #Tmp
select ident
ITy(int,1,1) as autoID, * into #Tmp from tableName
select min(autoID) as autoID into #Tmp2 from #Tmp group by Name,autoID
select * from #Tmp where autoID in(select autoID from #tmp2)
表名和重复字段名你跟着修改成你的数据库名和字段名就可以了