[英]SQL Server Management Studio - run multiple stored procedures in series
I would like to test 30 stored procedures against various input to see if any produce errors. 我想针对各种输入测试30个存储过程,以查看是否产生错误。 The stored procedure share the same parameters.
存储过程共享相同的参数。 When I run all of them (even just several of them) in SSMS, the execution runs and never completes.
当我在SSMS中运行所有它们(甚至只有几个)时,执行将运行并且永远不会完成。 It seems that maybe they are running in parallel and bogging down the server.
似乎它们正在并行运行并且使服务器瘫痪。 How can I instead execute the stored process in series without manually executing one at a time?
我该如何依次执行存储过程而不一次手动执行一个呢?
DECLARE @spResult int;
DECLARE @paramA int;
DECLARE @paramB int;
DECLARE @paramC int;
set @paramA = 2013
set @paramB = 1;
set @paramC = 10;
exec @spResult = rstoredProc1 @paramA ,@paramB ,@paramC
exec @spResult = rstoredProc2 @paramA ,@paramB ,@paramC
exec @spResult = rstoredProc3 @paramA ,@paramB ,@paramC
exec @spResult = rstoredProc4 @paramA ,@paramB ,@paramC
exec @spResult = rstoredProc5 @paramA ,@paramB ,@paramC
...
There are many ways to go about this. 有很多方法可以解决此问题。 Personally, I use an
IF
to keep the iteration going, and RETURN
if I don't get the success code back. 就个人而言,我使用
IF
来保持迭代的进行,如果没有RETURN
成功代码,则使用RETURN
。 In your case you could do something like : 在您的情况下,您可以执行以下操作:
EXEC @spResult = rstoredProc1 @paramA ,@paramB ,@paramC
IF @spResult <> 0
RETURN
ELSE
PRINT 'rstoredProc1 executed successfully'
EXEC @spResult = rstoredProc2 @paramA ,@paramB ,@paramC
IF @spResult <> 0
RETURN
ELSE
PRINT 'rstoredProc2 executed successfully'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.