如何处理数据流任务上的空查询结果?
我在 Foreach 循环内使用数据流迭代了几年,但有些年不会返回任何数据,因此它们 SSIS 包失败,有没有办法处理这个问题?告诉包忽略这些空白并继续执行?
谢谢,
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,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您不想改变数据传递到
Foreach
组件的方式,可以采取的一种方法是:您可以包含一个额外的
执行 SQL 任务
组件在Foreach
容器内,首先检查是否有任何数据要处理。创建一个变量,您的 SQL 任务将为其设置记录计数,例如
@cntProceed
设置此组件在您的数据流任务之前运行。
修改优先级约束(从 SQL 任务到数据流任务的绿色箭头)。将
求值操作
设置为表达式和约束
,将Value
设置为Success
,将Expression
设置为表达式
to@cntProceed != 0
这一切的作用是:在 foreach 组件/容器内,它将首先检查是否存在任何可以使用的数据。这就是附加组件将要做的事情,如果有数据要使用,它将继续到数据流组件。否则,
“each”
(或者更确切地说......那个循环)将结束,并且Foreach
将移至下一个。One approach you can take if you don't want to touch how the data is being passed to the
Foreach
component:You may include an additional
Execute SQL Task
component inside theForeach
container that checks first if there is any data to process.Create a variable to which your SQL task will set the record count to, for example
@cntProceed
Set this component to run before your Dataflow task.
Modify the precedence constraint (green arrow from your SQL task to your Dataflow task). Set the
evaluation operation
toExpression and Constraint
,Value
toSuccess
, andExpression
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 theForeach
will move to the next.我不确定如果查询返回 0 行,为什么数据流会失败。一种可能的解决方案是询问有效年份的数据,并且仅迭代有效年份。这可以通过以下方式完成:
您可以查看包装上的代码并将其发布吗?我很高兴看看是否可以重复您遇到的问题,并为您提供更直接满足您发布的需求的解决方案。
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:
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.