创建 SSIS 包以从众多数据源之一导入 [英] Create SSIS package to import from one of many data sources

查看:33
本文介绍了创建 SSIS 包以从众多数据源之一导入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以创建一个可以传递文件(通过变量)并根据变量确定要使用的数据流任务的 SSIS 包?

Is it possible to create an SSIS package that can be passed a file (through a variable) and from the variable determine which Data Flow Task to use?

我希望能够做的是创建一个单独的 DTSX 包,该包可以将文件名作为变量并检测(仅从文件名中)它是 Excel 2003、Excel 2007 或 CSV 文件以及来自即,执行正确的数据流任务.导入数据后,我将在另一个数据流任务中处理结果.

What I would like to be able to do is to create a single DTSX package that can take in a filename as a variable and detect (simply from the filename) if it is an Excel 2003, Excel 2007 or CSV file and from that, execute the correct Data Flow Task. I will then process the results in another single Data Flow Task after the data has been imported.

我很久以前就使用过 SSIS,现在我刚刚回来使用它,所以我的知识被锁定了,并且会慢慢恢复.我似乎不记得(或在 Google 上找到)在控制流中创建条件拆分的方法.

I used SSIS a long time ago and I am just coming back to using it so my knowledge is locked away and will come back slowly. I just can't seem to remember (or find on Google) a way of creating a conditional split in the Control Flow.

有什么想法吗?

推荐答案

正如 HLGEM 所说,只要内部结构一致,这样的事情就足够了.

As HLGEM has indicated, as long as the internal structure was consistent, something like this would suffice.

我已经声明了一个包级变量 DatFlowSelector 并且在我的初始脚本任务中,我将使用逻辑来根据 FileName 您将要使用的变量.

I'd declared a package level variable, DatFlowSelector and within my initial script task, I'd use logic to determine what path the flow should take based on the FileName variable you were going to use.

连接预期输出后,使用优先约束编辑器来确定哪个路径评估为真.我的逻辑很简单 @[User::DataFlowSelector] == N 其中 N 映射到我的脚本分配的值.

After wiring up the expected outputs, use the Precedence Constraint editor to determine what path evaluates to true. My logic was simply @[User::DataFlowSelector] == N where N maps to the value my script assigned.

我通常在修改约束时将 ShowAnnotation 属性切换为ConstraintOptions",因为它可以让未来的维护者立即清楚发生了什么事情.在这种情况下,SQL 2012 会有所帮助,因为它将 fx 字形分配给连接器,但显示逻辑可以提供对合理逻辑的一目了然的确认.

I generally switch the ShowAnnotation property to "ConstraintOptions" when I modify the constraints as it makes it immediately clear to future maintainers that there is something going on. SQL 2012 will help in this case as it assigns the fx glyph to the connector but displaying the logic can provide at-a-glance confirmation of sound logic.

这篇关于创建 SSIS 包以从众多数据源之一导入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆