SSIS中的动态OLEDB连接 [英] Dynamic OLEDB Connections in SSIS

查看:460
本文介绍了SSIS中的动态OLEDB连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在设计一个将数据从一个数据库导入其他数据库的SSIS包。实际上,我需要将数据从多个数据源导入到一个目标数据库。我知道的一种方法是使用所有数据源(连接字符串)的包配置,并运行同一个包的多个实例。但是我想要的是,我应该在配置文件的时间点提供尽可能多的连接字符串,我的包应该连接到从配置和导入到我的目标表的数据源连接字符串的每个数据库。

I am designing a SSIS package which imports data from one data base to other database. In reality I need to import data from multiple data source to one destination database. One way to do, that I know is to use package configuration for all data sources (connection strings) and run multiple instances of the same package. But I want something like, I should provide as many connection strings as I need at a point of time in my config file and my package should connect to each database reading data source connection strings from configuration and imports to my destination table.

这是否可能以任何方式?

Is this possible in any way?

推荐答案

如果您的数据流任务对于每个数据源(例如使用来自每个数据源的同一个表)将是一样的,您可以这样做:

If your Data Flow Task is going to be the same for every data source (e.g. using same table from each data source), you could do something like this:


  1. 创建一个对象变量,说ConnStrList。这将保存连接字符串列表。

  2. 在脚本任务中循环配置文件,并将每个连接字符串添加到ConnStrList。

  3. 添加一个ForEach循环容器,设置它的数据源到ConnStrList。创建一个字符串变量,说ConnStr。这将保存一个单独的连接字符串。将ConnStr设置为foreach循环的迭代变量。

  4. 在ForEach循环容器中添加数据流任务。

  5. 创建一个OLEDB连接管理器您的OLEDB源。转到属性 - >表达式和ConnectionString,分配变量ConnStr。

  1. Create an object variable, say ConnStrList. This will hold the list of connection strings.
  2. In a script task, loop through your config file and add each connection string to ConnStrList.
  3. Add a ForEach loop container, set it's data source to ConnStrList. Create a string variable, say ConnStr. This will hold an individual connection string. Set ConnStr as the iteration variable of the foreach loop.
  4. Add your Data Flow Task inside the ForEach loop container.
  5. Create an OLEDB connection manager for your OLEDB source. Go to Properties -> Expressions and for ConnectionString, assign the variable ConnStr.

如果每个场景的DFT将不同,您可能希望为每个来源提供单独的数据流。

If the DFT is going to be different for each scenario, you might want to have separate data flows for each source.

请让我知道,如果这回答您的问题,或者我遇到错误的情况。

Please let me know if this answers your question, or if I am getting the scenario wrong.

这篇关于SSIS中的动态OLEDB连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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