ahxcjxzxh 发表于 2016-11-2 07:40:25

SQL Server 一个简单的存储过程

create procedure Sstu @dept varchar(20),
            @avg_age smallint output,@max_age smallint output
AS
select * from Student where sdept=@dept
select @avg_age=avg(sage) from Student where sdept=@dept
select @max_age=max(sage) from Student where sdept=@dept
declare @avg_age smallint,@max_age smallint
exec   Sstu 'cs',@avg_age output,@max_age output
select @avg_age as avg,@max_age as max
页: [1]
查看完整版本: SQL Server 一个简单的存储过程