Home:ALL Converter>Conditionally Loop Through and Execute Stored Procedures in SQL Table

Conditionally Loop Through and Execute Stored Procedures in SQL Table

Ask Time:2015-03-07T14:23:19         Author:Erik

Json Formatter

I currently have a SQL Server table consisting of a number of stored procedures, each stored procedure belongs to a parent chapter. For example:

Stored procedures with IDs 1001-1199 belong to Chapter 1
Stored procedures with IDs 1200-1299 belong to Chapter 2
Stored procedures with IDs 1300-1399 belong to Chapter 3
etc...

Within context of SSIS I have created an ADO ForEachLoop container for each chapter and its stored procedures (8 chapter containers total). As of right now the intention is each chapter's loop will access an object variable containing the entire table and loop through each stored procedure that corresponds to that chapter, then execute it with an Execute SQL Task. What I am trying to do is figure out a simple way of selecting a given chapter's stored procedures conditionally from the object variable and executing them before moving on to the next chapter.

So, for example, Chapter 1's loop would select just stored procedures 1001-1199 from the table in the object variable and execute them, then proceed to the next chapter loop.

The idea of using the expressions on the precedent constraints between chapters occurred to me, but if I can apply a condition/expression to the collection of stored procedures by the loop container itself, that would seem ideal.

I am somewhat new to SSIS and SQL Server, and would appreciate any solution recommendations along with an explanation for my understanding. Please and thank you.

Author:Erik,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/28912057/conditionally-loop-through-and-execute-stored-procedures-in-sql-table
yy