ALTER proc xxxxx
as
declare @初值 int, @终值 int,@人员编号 int
declare @临时 table (编号 int IDENTITY(1,1),人员编号 int)
insert @临时
select distinct 人员编号 from xxx order by 人员编号
set @初值 = 0
select @终值 = count(*) from @临时
while (@初值 < @终值)
begin
set @初值 = @初值 + 1
select @人员编号 = 人员编号 from @临时 where 编号 = @初值
update xxxx set 发薪次数 = (select count(发薪日期) from xxxx
where 人员编号 = @人员编号) where 编号 = @人员编号
end
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO