Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
328 views
in Technique[技术] by (71.8m points)

sql server 2008 - Executing the same SSIS Package with different parameters at different time

I have a SSIS package running at 8 PM in the evening for the Year 2011.

I would like to run the same package at 8:30 PM for the Year 2010.

I made a SSIS Package configuration file and accept the "Year" as a parameter. Whenever I run, I need to open a file, change the value and run it.

Is it possible to set up the schedule and set the Year value dynamically?

Or using 2 different configuration file is the only way to solve it?

Thanks all.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The challenge with using a configuration file approach is that you would need to constantly modify the file. SSIS wouldn't reload the config file after it starts so you could conceivably have 8:05 and 8:35 PM jobs that swaps config files but that's going to get messy and break at some point.

I would handle this situation with command line variables (/set option in dtexec). If you were running the package from the command line, it'd look something like dtexec.exe /file MyPackage.dtsx Even if you're using SQL Agent, behind the scenes it's building those command line arguments.

This approach assumes you create two different jobs (vs 1 jobs scheduled 2x a day). AgentMyPackage2011 has a job step of SSIS that results in

  • dtexec /file MyPackage.dtsx /Set Package.Variables[User::Year].Properties[Value];"2011"

and AgentMyPackage2012 has a job step of SSIS that results in

  • dtexec /file MyPackage.dtsx /Set Package.Variables[User::Year].Properties[Value];"2012"

Through the GUI, it'd look something like SQL Agent Set values tab

SQL Agent Command line tab

There is no GUI or selector for the property you wish to configure. However, since you've already create a .dtsConfig file for your package, open that file up and look for a section like

<Configuration ConfiguredType="Property" Path="Package.Variables[User::Year].Properties[Value]" ValueType="Int32">
<ConfiguredValue>2009</ConfiguredValue>

The file already has the path to the "thing" you are attempting to configure so punch that into your calling program and then turn off the year portion of package configuration.

Finally, a link to SSIS Configuration Precedence as there are differences in the 2005 vs 2008 model. I see you indicated 2008 in your ticket but for future readers, if you're using both /SET and a configuration source (xml, sql server, registry, environment variable) the order of operations varies between versions.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...