是否可以从同一包中存在的脚本任务更改包?
在 SSIS 中...是否可以从包的脚本任务之一访问和更改包本身?如果是的话...您能举个例子吗?
例如,我想通过位于循环外部(之前)的脚本任务以编程方式配置 foreach 循环内的任务。比如读取文件并根据其内容添加/删除/配置任务。
感谢您抽出时间!
In SSIS... is it possible to access and change the package itself from one of its script tasks? If it is... could you please provide an example?
For instance, I would like to programmatically configure the tasks within a foreach loop from a script task located outside (before) the loop. Something like reading a file and add/removing/configuring tasks depending on its contents.
Thanks for your time!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
正如@Derek 已经提到的,不可能改变包本身。但是,您可以使用优先约束/表达式根据变量中存在的值来更改控制流任务的行为(如果这就是您更改包的意思)。
以下是我使用优先级约束根据表达式重定向/限制控制流任务的几个示例:
如何仅循环遍历以下文件使用 SSIS 包的目标中不存在?
如何根据存储过程输出停止包执行?
如何避免 SSIS FTP 任务在没有文件可供下载时失败?
(此示例使用脚本任务,后跟 Foreach 循环容器。)
< strong>如何将SQL语句输出写入CSV文件?
希望有所帮助。
As @Derek had already mentioned, it is not possible to alter the package itself. However, you can use precedence constraints/Expressions to alter the behavior of Control Flow tasks based on the value present in variable(s), if that is what you meant by altering a package.
Here are few examples where I have used precedence constraints to redirect/restrict the control flow tasks based on an expression:
How to loop through only files that don't exist in destination using an SSIS package?
How can I stop a package execution based on a stored procedure output?
How to avoid SSIS FTP task from failing when there are no files to download?
(This example uses a script task followed by a Foreach Loop container.)
How to write an SQL statement output to a CSV file?
Hope that helps.
不,这是不可能的 - 然而,我通过利用我多次重复使用的第二个“子”包做了一些非常类似的事情。在脚本中,您可以简单地清除子包,将所需的所有项目/容器/约束放入其中,然后执行它。
No, that's not possible - however, I do something very similar by utilizing a second "child" package that I reuse numerous times. In the script you can simply clear out the child package, put all of the items/containers/constraints you need into it, and then execute it.