您的位置:首页 > 博客中心 > 数据库 >

SQL_存储过程返回值

时间:2022-03-14 00:36

--定义存储过程
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

 

热门排行

今日推荐

热门手游