存储过程没有在另一个存储过程中执行 [英] Stored procedure not being executed within another stored procedure

查看:27
本文介绍了存储过程没有在另一个存储过程中执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现在执行 SP1 时 SP2 不会从 SP1 内执行.

I have found that SP2 doesn't execute from within SP1 when SP1 is executed.

以下是SP1的结构:

ALTER PROCEDURE SP1 AS BEGIN

Declare c1 cursor....

open c1 fetch next from c1 ...

while @@fetch_status = 0 Begin

...

Fetch Next from c1 end

close c1

deallocate c1

exec sp2

end

<小时>

如果打印在 SQL Server 2005 管理工作室的输出窗口"中,因为输出窗口"为空,我看不到任何 PRINT 语句输出.


I see non of the PRINT statement outputs if they are printed in the 'Output window' in SQL Server 2005 management studio as the 'Output Window'is empty.

推荐答案

如果将存储过程代码作为单个查询运行会发生什么?如果你在 exec 之前和之后放一个 PRINT 语句,你能看到两个输出吗?

What happens if you run the Stored Procedure code as a single query? If you put a PRINT statement before and after the exec, do you see both outputs?

  • 如果你这样做了,那么存储过程一定已经被执行了.可能它没有按照您的意愿行事.
  • 如果您没有看到任何打印输出,则说明循环有问题
  • 如果您没有看到第二个输出,但看到了第一个输出,则第二个存储过程有问题.

这篇关于存储过程没有在另一个存储过程中执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆