码迷,mamicode.com
首页 > 其他好文 > 详细

存储过程

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

标签:style   ar   color   使用   sp   数据   bs   ef   as   

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

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

存储过程

标签:style   ar   color   使用   sp   数据   bs   ef   as   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!