简体   繁体   English

SQL Server Management Studio-连续运行多个存储过程

[英]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.

相关问题 在 SQL Server Management Studio 中调试存储过程 - Debugging stored procedures in SQL Server Management Studio 阻止SQL Server Management Studio向存储过程添加注释 - Stop SQL Server Management Studio from adding comment to stored procedures 重新组织SQL Server Management Studio中的存储过程显示 - Reorganise Stored Procedures display in SQL Server Management Studio 启动多个存储过程以在SQL Server Express Edition上“在后台”运行 - Launch multiple stored procedures to run 'in the background' on SQL Server Express Edition SQL Server Management Studio 2014:无法在Azure SQL数据库V12上查看存储过程 - SQL Server Management Studio 2014: Unable to view stored procedures on Azure SQL Database V12 在存储过程中是否会更改Microsoft SQL Server Management Studio中的列名? - Will changing the name of a column in Microsoft SQL Server Management Studio be reflected in stored procedures? 如何从SQL Server Management Studio中的表生成CRUD存储过程 - How do I generate CRUD stored procedures from a table in SQL Server Management Studio SQL Server Management Studio中需要哪些数据库角色来添加和执行存储过程 - Which database roles are needed in SQL Server Management Studio to add and execute stored procedures 如何使用SQL Server Management Studio将所有存储过程从一个数据库传输到另一个数据库 - How to transfer all stored procedures from one database to another with SQL Server Management Studio 在Visual Studio中管理SQL Server存储过程 - Manage SQL Server stored procedures in Visual Studio
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM