如何调用存储过程的返回值??

silverysky 2003-11-18 12:17:34
例如:执行存储过程test得到的结果是4
如何能把这个值赋给一个变量a呢??
谢谢各位啦
...全文
34 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
shuiniu 2003-11-18
  • 打赏
  • 举报
回复
写错了!
declare @a int
exec @a = test
select @a
shuiniu 2003-11-18
  • 打赏
  • 举报
回复
declare @a int
exec @a = test
select @int
??
Rotaxe 2003-11-18
  • 打赏
  • 举报
回复
declare @a int
exec test @参数名=@a
zjcxc 元老 2003-11-18
  • 打赏
  • 举报
回复
--存储过程有两种返回值的情况,看你的存储过程是怎么样写的.

--第一种
create proc p1
as
return(4)
go

--第二种
create proc p2
@re int output
as
set @re=4
go


--调用方法
declare @re int

--调用第一个的方法
exec @re=p1

--调用第二个的方法
exec p2 @re out
pengdali 2003-11-18
  • 打赏
  • 举报
回复
declare @a int

exec test @a output

select @a 结果
cloudchen 2003-11-18
  • 打赏
  • 举报
回复
create proc b
@s varchar(100) output
as
select @s='cloudchen'
go

declare @str varchar(100)
exec b @s = @str output
select @str
go

drop proc b

34,587

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧