--假如存在存储历程proc_addWage1就删除
ifexists(select*fromsysobjectswherename=proc_addWage1)
dropprocedureproc_addWage1
go
--创立存储历程proc_addWage1
createprocedureproc_addWage1
as
setnocounton
declare@firstwageint
select@firstwage=sum(wage)fromprowage
while(1=1)
begin
declare@notpassint,@countint--界说两个变量没到达2200的人数和总人数
select@notpass=count(*)fromprowagewherewage<2200
select@count=count(*)fromprowage
if(@notpass*2>@count)
updateprowagesetwage=wage+100
else
break
end
declare@endwageint
select@endwage=sum(wage)fromprowage
print一共加薪+convert(varchar(5),@endwage-@firstwage)
print加薪后的程序员人为列表:
selectID,Pname,wagefromprowage
go
--假如存在存储历程proc_addWage2就删除
ifexists(select*fromsysobjectswherename=proc_addWage2)
dropprocedureproc_addWage2
go
--创立存储历程proc_addWage2
createprocedureproc_addWage2
as
setnocounton
while(1=1)
begin
declare@avgwageint--界说变量均匀人为
select@avgwage=avg(wage)fromprowage
if(@avgwage<4500)
updateprowagesetwage=wage+200
else
break
end
go