真的真很麻烦你了,我都不好意思了. declare @max int declare @id varchar declare cur_rows cursor local for select 出口规格,count(*) from 轧硬卷 group by 出口规格 having count(*) > 1 open cur_rows fetch cur_rows into @id,@max while @@fetch_status=0 begin select @max = @max -1 set rowcount @max insert into 表1 values(@id,@max,) delete from 轧硬卷 where 出口规格 = @id fetch cur_rows into @id,@max end close cur_rows set rowcount 0