
帮忙解释一个SQL Server 中存储过程的输入和输出参数的区别
--3创建带输入,输出参数的存储过程ifexists(selectnamefromsysobjectswherename='h3'andtype='p')dropproc...
--3创建带输入,输出参数的存储过程
if exists(select name from sysobjects
where name='h3'and type='p')
drop procedure h3
go
create procedure h3 @p1 int,@p2 char(30) output
as
select @p2=s_name
from stu
where s_id=@p1
go
--调用该存储过程
declare @out char(30)
exec h3 1002,@out output
select @out
go
上面的这个存储过程怎么来理解,新手,求指教!!! 展开
if exists(select name from sysobjects
where name='h3'and type='p')
drop procedure h3
go
create procedure h3 @p1 int,@p2 char(30) output
as
select @p2=s_name
from stu
where s_id=@p1
go
--调用该存储过程
declare @out char(30)
exec h3 1002,@out output
select @out
go
上面的这个存储过程怎么来理解,新手,求指教!!! 展开
展开全部
1. 如果存储过程h3已经存在,就drop掉
2. 创建存储过程h3
参数P1,P2,其中P2为输出参数
存储过程功能:取学号为P1的学生姓名,由P2输出
3. 定义变量,调用存储过程,返回学号是1002的学生姓名
2. 创建存储过程h3
参数P1,P2,其中P2为输出参数
存储过程功能:取学号为P1的学生姓名,由P2输出
3. 定义变量,调用存储过程,返回学号是1002的学生姓名
展开全部
1 如果 过程h3已经存在 就drop 过程h3
if exists(select name from sysobjects
where name='h3'and type='p')
drop procedure h3
2 创建 过程h3 ,p1是传入参数,p2是传出参数
create procedure h3 @p1 int,@p2 char(30) output
as
select @p2=s_name
from stu
where s_id=@p1
go
3 定义一个变量out,
declare @out char(30)
4 然后执行过程h3,1002 作为传入的参数值,out作为h3的传出参数
exec h3 1002,@out output
5 显示out的值
select @out
if exists(select name from sysobjects
where name='h3'and type='p')
drop procedure h3
2 创建 过程h3 ,p1是传入参数,p2是传出参数
create procedure h3 @p1 int,@p2 char(30) output
as
select @p2=s_name
from stu
where s_id=@p1
go
3 定义一个变量out,
declare @out char(30)
4 然后执行过程h3,1002 作为传入的参数值,out作为h3的传出参数
exec h3 1002,@out output
5 显示out的值
select @out
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
如果在库中有过程名为H3的就先删除,
然后创建含有输入参数P1,和输出参数P2的过程H3过程,显示内容为P2,其中P2为STU表中的S_NAME字段,条件是S_ID为你输入的那个P1值,
declare @out char(30) --定义变量
exec h3 1002,@out output --执行H3过程,P1=1002,P2=@out
select @out --查询输出结果
go
然后创建含有输入参数P1,和输出参数P2的过程H3过程,显示内容为P2,其中P2为STU表中的S_NAME字段,条件是S_ID为你输入的那个P1值,
declare @out char(30) --定义变量
exec h3 1002,@out output --执行H3过程,P1=1002,P2=@out
select @out --查询输出结果
go
追问
显示内容为P2,您说得这句怎么理解?真得很菜,不好意思。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询