December 2005 - Posts

Self Modifying Packages in SSIS?

Yeah, thought that might get your attention. :)

First, packages cannot modify themselves during execution. There is no package pointer passed to the tasks any longer, so you can't traverse the package object model with the script task any longer. That is, you can't traverse the package object model for package in which the script task resides. You CAN however open and modify other packages, including those that the parent package is about to execute with the Execute Package task. This is the same model as self modifying packages in DTS, except it's safer because you're not attempting to change the package as it is running.

Here's the script from a chapter of my book that shows you how to modify a Transfer Objects Task to move some tables. There is no error handling code for clarity, bla bla bla. The usual caveats apply, check for errors, handle exceptions.

The Script

Imports System.Collections.Specialized

Public Sub Main()

  Dim application As Microsoft.SqlServer.Dts.Runtime.Application = New Application()

  Dim packagename As Object = Dts.Connections("Tables").AcquireConnection(Nothing)

  Dim package As Microsoft.SqlServer.Dts.Runtime.Package = application.LoadPackage(packagename.ToString(), Nothing)

  Dim th As TaskHost

  th = package.Executables("TablesToMove")

  Dim sc As StringCollection = New StringCollection()

  sc.Add(Dts.Variables("Tables1").Value.ToString())

  sc.Add(Dts.Variables("Tables2").Value.ToString())

  th.Properties("TablesList").SetValue(th, sc)

  application.SaveToXml(packagename, package, Nothing)

  Dts.TaskResult = Dts.Results.Success

End Sub

This is some quick and dirty code that uses the package object model to open the child package and modify it.

Table Names

In the parent package there are a couple of variables I use, Tables1 and Tables2, to change the table I want to move. Now, you can change this how you want. Stick them all in a comma delimited string if you want and parse them out in script or stick them in a variable one-by-one with a ForEach Nodelist Enumerator. It doesn't really matter how you get the table names into the script.

The Package Connection

The script uses the same Connection Manager as the Execute Package task to find the name of the package to open and modify.

Modifying the Package

Now the property type for the Transfer Objects Task for the TableList is a StringCollection. So, I create a StringCollection in script and populate it. Then I open the child package, the one that will be moving tables, and set the property on the Transfer Objects Task and save the package again.

Here's the parent package with the script task and the Execute Package task.

This is the script task UI. Notice the variables that I'm referencing.

 

Finally, this is the child package, pretty simple. Has just the Transfer Objects task.

 

Notice that the tables selected to be moved in the Transfer Objects Table are the same as those specified in the variables on the parent package.

Easy right!

Universe.Earth.Software.Microsoft.SQLServer.IS.KirkHaselden

Integration Services Error, Warning and Information Messages

This seems to have quietly appeared on MSDN.  I knew it was going to be available soon, but didn't notice it until today when searching for something related.

Integration Services will sometime emit errors with cryptic hex numbers. The full list of errors is now available in one place with the hex numbers and descriptions.

http://msdn2.microsoft.com/en-us/library/ms345164.aspx

Enjoy,

Universe.Earth.Software.Microsoft.SQLServer.IS.KirkHaselden

Merry Christmas

Season's Greetings

System table map available for download

This was available in the December SQL Server Magazine and is now available for downloading from Microsoft.

http://www.microsoft.com/downloads/details.aspx?familyid=2ec9e842-40be-4321-9b56-92fd3860fb32&displaylang=en

Universe.Earth.Software.Microsoft.SQLServer.IS.KirkHaselden

 

SQL Server 2005 BI Metadata Samples Toolkit now available

The Metadata Samples Toolkit provides tools for analysis and visualization of lineage and dependencies across SSIS and SSAS metadata as well as SSRS report model and samples.

This is a very compelling way to visualize data flow-through, impact analysis, and dependencies.

http://www.microsoft.com/downloads/details.aspx?FamilyId=11DAA4D1-196D-4F2A-B18F-891579C364F4&displaylang=en

Great work Anjan Das, Ashvini Sharma, Michael Entin, and Wenyang Hu!

K

Hands on Training Labs

Another worthwhile and interesting download became available recently.

The Hands on Training Labs.

Find them here: http://www.microsoft.com/downloads/details.aspx?FamilyID=b1145e7a-a4e3-4d14-b1e7-d1d823b6a447&DisplayLang=en

Rock on!

Universe.Earth.Software.Microsoft.SQLServer.IS.KirkHaselden

Integration Services Logging Reports

For those of you who have been waiting for some time after seeing me or some of the other team demonstrate these reports, they are finally available.

For those of you who haven't seen them, they are a set of reports that key off SQL Server logging from packages to show when packages were run, error rows from the dataflows, packages duration, errors, and other information. The reports are a great way to get a package execution status or history.

You need to have Reporting Services installed and you'll need to deploy some reports and set up your packages to log to SQL Server, but all that is explained in the download.

http://www.microsoft.com/downloads/details.aspx?FamilyID=526e1fce-7ad5-4a54-b62c-13ffcd114a73&DisplayLang=en

Kudos to Craig Guyer and Grant Dickinson

Enjoy,

Universe.Earth.Software.Microsoft.SQLServer.IS.KirkHaselden