--存储过程(在数据库的可编程性里面)

create proc chaxun
as
begin
 select *from student
end
go
--执行
exec chaxun
--删除
drop proc chaxun
--修改
alter proc chaxun
as
begin
 select *from hj
end
go

/*=====================输入一个数,求这个数的阶乘的和=====================*/
create proc jiechenghe
@p int,@w int output,@h int output    --output导出参数时使用
as
begin
     declare @s int
     set @w=1
     set @s=1
     set @h=0
     while @s<=@p       --while 代表循环的意思
           begin
             set @w=@s*@w
             set @s=@s+1
             set @h=@h+@w
           end
end
go
declare @c int,@c1 int                --新建函数是为了导出参数使用的
exec jiechenghe 6,@c output,@c1 output
print @c             --print输出结果
print @c1

//return 也是导出参数但是只能导出一个参数且表达方式是int型的