开发者

Do SSIS Config Files support the DRY (Don't repeat yourself) principal?

We have a slew of SSIS packages that process files in a specified root "Data" folder location and load it to a specified destination database.

Naturally, the root input folder changes across the development and production environments as does the destination database.

For specific input files, we may hav开发者_开发百科e a subfolder off of the root Data folder but the file directory structure in Development matches production; only the root folder location is different.

I can easily have a single DtsConfig file to control the database conection by changing the contents of this file depending on whether the file in Development or a production Environment.

The key part: However, the ConnectionStrings for the files are not as straight forward. ideally, I would like to be able to specify a file Connectionstring path in the form of %RootFolder%\SourceSystemA\HardCodeFileName.txt where %Rootfolder% varies depending on the environment.

However, short of writing script to modify the package at run time (I haven't seen any examples) or creating the entire package programmatically, I don't think that this can be done. Using Environmental variables in this way to be applied to only a portion of a package property does not appear to be supported. (Try it!) Relative paths also don't seem to be supported (although our files are on a different drive, so this may not have helped.)

Not sure if the "DRY" principal as I understand it is relevant here, but basically, I want to separate those things that are static from those things that change and allow for easy update in ONE place and have it apply everywhere.

How can this be accomplished?


It's not perfect, but I do have a method of doing this. First, add a variable to the package to hold the root folder name. Next, click on your connection and go to properties (F4). Modify the "Expressions" by clicking the "..." button. Create an expression for the Connection String. For the expression, you can combine your root folder with your specific filename (eg, @[User::RootFolder] + "\SpecificPath\Filename.csv").

Once you have this set up, then you can use a config file to change the RootFolder package variable, and all the files will then be read/written correctly using it.

In answer to the title question - SSIS supports DRY in some places, and doesn't in others. For what you are trying to do, the answer is yes (via Expressions as outlined above).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜