码迷,mamicode.com
首页 > 数据库 > 详细

SQL_存储过程返回值

时间:2014-10-05 23:27:29      阅读:294      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   ar   sp   div   c   log   r   

--定义存储过程
create procedure GetOutInfo
@className nvarchar(50),
@Age int,
@maxScore int output,
@avrageScore int output,
@stuCount int output
as 
begin
select * from Students where ClassName=@className and Age>@Age
select @maxScore=MAX(chinese) from Students where ClassName=@className and Age>@Age
select @avrageScore=AVG(chinese) from Students where ClassName=@className and Age>@Age
select @stuCount=COUNT(*) from Students where ClassName=@className and Age>@Age
end

go

--调用存储过程
declare @max_score int
declare @avg_score int
declare @count_stu int
exec GetOutInfo 高三一班,18,@max_score output,@avg_score output,@count_stu output
select zuigaofen=@max_score,pingjunfen=@avg_score,renshu=@count_stu

 

SQL_存储过程返回值

标签:style   blog   color   ar   sp   div   c   log   r   

原文地址:http://www.cnblogs.com/zwhFighting/p/4007505.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!