Go Back   CORTEX Forums > Local Happenings > CORTEX Blogs > BI Monkey
Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read

Modifying an SSIS Package through code

This is a discussion on Modifying an SSIS Package through code within the BI Monkey forums, part of the CORTEX Blogs category; Part of any SSIS development experience inevitably results in you discovering a minor mistake or something that was missed a long way into the development cycle – or even after, ...


Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 3rd September 2010, 12:29 AM   #1
Guru
 
Join Date: Jun 2009
Posts: 122
James Beresford is on a distinguished road
Thumbs up Modifying an SSIS Package through code

Part of any SSIS development experience inevitably results in you discovering a minor mistake or something that was missed a long way into the development cycle – or even after, in testing (you do test your code, right?). Then you are faced with the tedious job of opening every single package, making a change in every one… and getting some serious mouse finger. Much like I once did when I learned about BufferTempStoragePath.

Fortunately, there is a way to automate these fixes. The SSIS Object model is (relatively) easily manipulated through .NET languages – so it’s not too difficult to write a small program that will change your package. Below is a sample I knocked up that will add a variable to an existing package and save the change:
using System;
usingMicrosoft.SqlServer.Server;
usingMicrosoft.SqlServer.Dts.Runtime;

namespace Package_Modifier
{
*** class Program
*** {
******* static void Main(string[] args)
******* {
*********** // Initialize an Application and Package object
*********** Application app = new Application();
*********** Package package = null;

*********** // Set a package path
*********** StringpkgPath = “C:\\BI Monkey\\SamplePackage.dtsx”;

*********** // Load the package in package object
*********** package = app.LoadPackage(pkgPath, null);

*********** // Add the new variable
*********** package.Variables.Add(“NewVar”, false, “User”, 0);


*********** // Save the package
*********** app.SaveToXml(pkgPath, package, null);
********* }
*** }
}

You can essentially make any change you like to a package – I’ve chosen adding a variable because it’s an*easy manipulation of the*package object*and I’ve got a long way to go before I work out how to do anything much harder



Get More from the original blog...
James Beresford is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiTweet this Post!
Reply With Quote
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
SSIS ETL Framework v1 goes Beta! James Beresford BI Monkey 0 9th August 2010 02:53 PM
The BI Monkey SSIS ETL Framework James Beresford BI Monkey 0 12th April 2010 02:49 AM
SSIS Loops that do not fail James Beresford BI Monkey 0 3rd August 2009 07:05 PM
Do? While / Until Loops in SSIS James Beresford BI Monkey 0 23rd July 2009 10:30 PM
Infinite (code)monkeys? Gruden Gruden 0 26th June 2009 02:08 PM


All times are GMT +11. The time now is 03:02 PM.

© The Business Intelligence Group

Search Engine Optimization by vBSEO