output引用类型

1.创建存储过程,将参数avg设置为引用参数,可以对参数有反馈作用

create procedure sp_goods_price_avg 
(
@name
nvarchar(255),
@avg float output
)
as select @avg=AVG(price) from goods where gname=@name go

2.执行存储过程,传入参数时也是用output关键字

declare @avg float;
exec sp_goods_price_avg '电视', @avg output;
print @avg;

 

posted @ 2017-10-12 09:33  fight139  阅读(128)  评论(0编辑  收藏  举报