如何在不复制/粘贴的情况下在 SSIS 中重用任务?
例如,我想将我在事件处理程序中定义的任务用于另一个可执行文件中的一个可执行文件,但不使用包中的所有可执行文件。到目前为止,除了编写一个完整的自定义组件之外,我还没有找到任何解决方案,这似乎有点矫枉过正。有什么建议么?
如何在不复制/粘贴的情况下在 SSIS 中重用任务?
例如,我想将我在事件处理程序中定义的任务用于另一个可执行文件中的一个可执行文件,但不使用包中的所有可执行文件。到目前为止,除了编写一个完整的自定义组件之外,我还没有找到任何解决方案,这似乎有点矫枉过正。有什么建议么?
Have you considered using an event at the package level, and filtering to only fire when your particular condition requires it?
E.g. you could use the OnPostExecute event just by putting a dummy task in your flow with a name that starts with a specific string like "RunMyTasks", and then check the System::SourceName to see if it starts with "RunMyTasks". If it does, then branch to run your tasks (and otherwise branch to handle the event as you normally would).
You could do a similar thing using OnVariableValueChanged - this might be better (although you'd need to test it). Create a variable with RaiseChangedEvent=TRUE. Create a script task / component to change the value of the variable; finally, put your task set into the event handler. Check the scoping notes at the bottom of Jamie's post here.
如果您可以使用第三方解决方案,请查看商业CozyRoc SSIS+库。它包括增强的 Script Task Plus,它允许将脚本导出到外部文件,然后在其他包中链接和重用。