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]