Domanda

I'm iterating several years with a Dataflow inside a Foreach Loop, but there are some years that will not return any data, therefore they SSIS package fails, is there a way to handle this? To tell the package to ignore those blanks and keep executing?

Thanks,

È stato utile?

Soluzione

One approach you can take if you don't want to touch how the data is being passed to the Foreach component:

  1. You may include an additional Execute SQL Task component inside the Foreach container that checks first if there is any data to process.

  2. Create a variable to which your SQL task will set the record count to, for example @cntProceed

  3. Set this component to run before your Dataflow task.

  4. Modify the precedence constraint (green arrow from your SQL task to your Dataflow task). Set the evaluation operation to Expression and Constraint, Value to Success, and Expression to @cntProceed != 0

What this all does: Inside the foreach component/container it will first check if there exists any data to work with. That's what the additional component will do, and if there's data to use, it will proceed to the dataflow component. Otherwise, that "each" (or rather.. that one loop) will end and the Foreach will move to the next.

Altri suggerimenti

I'm not sure why a data flow would fail if a query returns 0 rows. One possible solution is to interrogate your data for the valid years and only iterate through valid years. This could be done by:

  1. Create an Execute SQL task before the ForEach Loop container
  2. Set the ResultSet to full rows for the Execute SQL task
  3. Set the Result Set tab to an object variable
  4. Set the ForEach Loop container to a ForEach ADO Enumerator
  5. Set the ADO object source variable to the object variable
  6. Set the Variable Mappings to a variable for the year
  7. Pass the year as a parameter to the data flow.

Can you View Code on the package and post that? I'd be happy to see if I can duplicate the problem you are experiencing and give you a solution that more directly meets your posted need.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top