sql server 中关于存储过程的问题,下面是存储过程的代码,但是执行报错,请教原因?
ifexists(select*fromsysobjectswheretype='p'andname='Sum_wage')dropprocedureSum_wagego...
if exists(select * from sysobjects where type = 'p' and name = 'Sum_wage')
drop procedure Sum_wage
go
create procedure Sum_wage
@Pwage int,
@Awage int,
@total int
as
while(1=1)
begin
if(select count(*) from PraWage)>2*(select count(*) from PraWage where wage>=@Pwage)
update PraWage set @total=@total+@Awage,wage=wage+@Awage
else
break
end
print '一共加薪:'+convert(varchar(10),@total)+'元'
print '加薪后的程序员工资列表:'
select * from PraWage
go
--调用存储过程--
exec Sum_wage @Pwage=2000,@Awage=100,@total=0
exec Sum_wage @Pwage=2200,@Awage=100,@total=0
exec Sum_wage @Pwage=3000,@Awage=100,@total=0
exec Sum_wage @Pwage=3500,@Awage=100,@total=0
exec Sum_wage @Pwage=4000,@Awage=100,@total=0
exec Sum_wage @Pwage=5000,@Awage=100,@total=0
exec Sum_wage @Pwage=6000,@Awage=100,@total=0
报错:消息 208,级别 16,状态 1,过程 Sum_wage,第 8 行
对象名 'PraWage' 无效。
请教数据库高手解答,谢谢! 展开
drop procedure Sum_wage
go
create procedure Sum_wage
@Pwage int,
@Awage int,
@total int
as
while(1=1)
begin
if(select count(*) from PraWage)>2*(select count(*) from PraWage where wage>=@Pwage)
update PraWage set @total=@total+@Awage,wage=wage+@Awage
else
break
end
print '一共加薪:'+convert(varchar(10),@total)+'元'
print '加薪后的程序员工资列表:'
select * from PraWage
go
--调用存储过程--
exec Sum_wage @Pwage=2000,@Awage=100,@total=0
exec Sum_wage @Pwage=2200,@Awage=100,@total=0
exec Sum_wage @Pwage=3000,@Awage=100,@total=0
exec Sum_wage @Pwage=3500,@Awage=100,@total=0
exec Sum_wage @Pwage=4000,@Awage=100,@total=0
exec Sum_wage @Pwage=5000,@Awage=100,@total=0
exec Sum_wage @Pwage=6000,@Awage=100,@total=0
报错:消息 208,级别 16,状态 1,过程 Sum_wage,第 8 行
对象名 'PraWage' 无效。
请教数据库高手解答,谢谢! 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询