Chris
Chris

Reputation: 1

Use Foreach Loop in SSIS to see if a condition is met then move to next container

Trying to use a query like this:

Select * from MyTable
where CompletedDate >= [@PackageStartTime]

Query I have in my SQL Task:

Select * from MyTable
where CompletedDate >= ?

Need to loop through the query to see if the condition is met and if it is, move to the next task and if not, keep looping until the condition is met.

Tried using this Query in SQL Task with a variable name of [@StartTime] and Result Set of Result Name = 0 and Variable Name = User:Query to put the results in. The User:Query is set to Object.

In the Foreach Loop container below that is the Collection "Foreach ADO Enumerator" and ADO object source variable: User:Query and Enumeration mode: Rows in the first table.

I think I got the first part working but what do I put in the Foreach Loop container at this point? I need a variable to say that condition is TRUE to move on to the next task.

Upvotes: 0

Views: 443

Answers (1)

droptable42
droptable42

Reputation: 1

I'd use a sql task to give me a constraint to work with. Something like below...

SELECT COUNT(*) FROM MyTable WHERE CompletedDate >= @PackageStartTime

Then save the result set to a var and setup a constraint to your next task. Something like this

@[User::RowCount] > 0

Upvotes: 0

Related Questions