首页 > 其他 > 详细

存储过程

时间:2014-12-01 19:01:12      阅读:150      评论:0      收藏:0      [点我收藏+]

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

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型的

存储过程

原文:http://www.cnblogs.com/2041388565m/p/4135749.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!