问题
I'm hoping someone can offer another couple of points of view on an issue I am having with SSIS sequence containers. I am relatively new to sequence containers and they are accomplishing what need to be done, but here's the situation: Let's suppose I have three sequence containers and they all process files. Containers A, B, and C. Container A will always process because it unzips files, but container B may not perform actions based on whether or not a file exists and the same with container C. All containers contain other tasks which work fine. I have tried using constraints between the containers by evaluating the file name as such using expressions, but that doesn't seem to work. I'm not sure if the answer is to put a script task inside the dataflow task in the sequence container to look at the file name and then say, if the file is present, process it and if not, move on.
Any help would be appreciated. Thanks so much.
回答1:
If I understand your problem. Sequence Container A always runs because it is looking for .zip files which downstream containers are dependent upon. The desire is to disable the dependent items if the parent didn't satisfy some criteria (found archives to unzip).
The quickest/codefree way would be to wrap the two Sequence Containers inside a Foreach Loop Container. That would fire off, find no file to process and never invoke the inner containers.
A script task, which is a control flow element, is fine and dandy and you can either enable/disable the containers or enable/disable the precedence constraint.
Either one can be the right approach, depending on your business needs.
Based on the comments below, I would probably pattern my package as this. The Sequence container encapsulates all the things that need to happen if data is available. The Sequence Container is the easy check that my file is there. This does assume a simple file existence check is sufficient. If files A and Z were required, then a Script Task will be easier.
Configuration of a ForEach Loop Container. I generally use the Expressions under the Enumerator section (and assign based on Variables instead of the hardcoded values displayed) as this allows me the greatest flexibility.
来源:https://stackoverflow.com/questions/20057482/ssis-sequence-container-setting-conditional-parameters-for-when-file-is-not-pre