存储过程调用存储过程

igelf 2008-12-31 10:22:33
存储过程A,

存储过程B
@intcount int output
AS
begin
set @intcount=55;
end

如果A要调用B

exec B @intcount

print @intcount

不能返回值的.

请问能返回值吗.怎么改.
...全文
123 8 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
Liyingyue_FFS 2008-12-31
  • 打赏
  • 举报
回复
exec B @intcount output
print @intcount
mjtalhx 2008-12-31
  • 打赏
  • 举报
回复
exec B @intcount output

print @intcount
Zoezs 2008-12-31
  • 打赏
  • 举报
回复
如果调用只为得到一个参数直接用output就可以解决,
如果是记录集的话,建一个临时表,表结构同筛出来的记录集,直接insert into 即可。
百年树人 2008-12-31
  • 打赏
  • 举报
回复
--存储过程B
if object_id('B')is not null drop proc B
go
create proc B
@intcount int output
AS
begin
set @intcount=55;
end
go
--存储过程A,A调用B
if object_id('A')is not null drop proc A
go
create proc A
AS
declare @intcount int
exec B @intcount output
print @intcount
go

--执行存储过程A
exec A

--结果

55
hlq8210 2008-12-31
  • 打赏
  • 举报
回复
create proc #t
@intcount int output
as
set @intcount=5



declare @a int
set @a=0
exec #t @a output
select @a
chuifengde 2008-12-31
  • 打赏
  • 举报
回复
create proc b
@in int out
as
set @in=10

go
create proc a
as
declare @x int
exec b @x out
print @x
rucypli 2008-12-31
  • 打赏
  • 举报
回复
把B直接替换了exec B
快乐_石头 2008-12-31
  • 打赏
  • 举报
回复
if object_id('proc_b')is not null drop proc proc_b
go
create proc proc_b
@intcount int output
AS
set @intcount=55;
go
declare @intcount int
exec proc_b @intcount output
print @intcount
/*55
*/

34,837

社区成员

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

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