Referencing variable in child package from parent package via SQL Server-based configuration
Environment
SQL Server 2005 SP3
Server:
Microsoft SQL Server Management Studio 9.00.4035.00
Microsoft Analysis Services Client Tools 2005.090.4035.00
Microsoft Data Access Components (MDAC) 2000.086.3959.00 (srv03_sp2_rtm.070216-1710)
Microsoft MSXML 2.6 3.0 5.0 6.0
Microsoft Internet Explorer 6.0.3790.1830
Microsoft .NET Framework 2.0.50727.3620
Operating System 5.2.3790
Development Workstation:
Windows XP Professional x64 Edition Version 2003 Service Pack 2
Microsoft Visual Studio 2005 Version 8.0.50727.762 (SP.050727-7600)
Microsoft .NET Framework Version 2.0.50727 SP2
Installed Edition: IDE Standard
Microsoft Visual Studio 2005 Premier Partner Edition - ENU Service Pack 1 (KB926601)
Microsoft SQL Server Analysis Services Designer Version 9.00.4035.00
Microsoft SQL Server Integration Services Designer Version 9.00.4035.00
Microsoft SQL Server Reporting Services Designers Version 9.00.4035.00
I am struggling a bit with managing a set of packages that I have developed in my local environment and wish to deploy at a remote site while making effective use of Package Configurations.
I need to process about 400 tables in all. I have created 42 packages to process the data from these tables. Some packages are self-contained, and will extract data from a set of related tables on one SQL
Server instance on one server and insert that data into a set of tables on another SQL Server instance on another server. Some packages will extract data from a single table on one SQL Server instance on one server and write the data to a reachable filesystem
as a Unicode Flatfile. Some packages will read the data from the single Unicode Flatfile (after some offline script processing) and upload it to a table on another SQL Server instance on another server. Some will extract data from a set of related tables on
one SQL Server instance on one server and write it to reachable filesystem as a multi-worksheet Excel spreadsheet file. Some will read the data from the single Excel spreadsheet file and upload it to a table on another SQL Server instance on another server.
So, there are a number of servers, SQL Server instances, and file locations to specify at a controlled customer site at runtime.
I have tested all of the individual packages successfully. I have added the packages to a parent/executive package that will control overall execution sequencing. I have also built the entire Project in
MSVS2005.
I created a configuration that will allow running the Project on varying servers and databases - following the suggested path < http://msdn.microsoft.com/en-us/library/cc671625.aspx> of
(a) Uploading a table into a SQL Server instance on a server that contains configuration information about all of the servers, databases, files and directories that the packages (mostly the various connection
managers) will use.
(b) Creating a System Environmental variable to provide connection string information to a parent package, which will in turn allow access to the table in (a).
(c) Having the other packages access the information from the table in (a) via the parent/child package configuration variable passing mechanism.
An example configuration table entry (in this case for the name of one of the servers hosting one of the target/destination SQL Server instances) is:
Configuration Filter
412to512
ConfiguredValue
TARGETDB1
PackagePath
\Package.Connections[CONFIGDB.ssis_configuration].Properties[ServerName]
ConfiguredValueType
String
How specifically do I reference this configuration table row entry in the parent package and pass it on to a child package? All hints appreciated!
May 12th, 2011 1:04pm
See if bullet #2 in this post http://social.msdn.microsoft.com/Forums/en/sqlintegrationservices/thread/84f6808b-4772-4066-9f17-03fea708d1eb is helpfulArthur My Blog
Free Windows Admin Tool Kit Click here and download it now
May 12th, 2011 2:29pm
Thanks for the reply.
> bullet #2
I actually did get that far, and can link a user-defined variable in the parent package to a Package Configuration defined in the child task, but do not understand how to
set the user-defined variable in the parent package *from* the information stored in SQL Server that is referred to in the parent package (SQL Server Type) Package Configuration.
(Note that I am not using an .xml configuration file to create/store/access my configurations.)
Further ideas or links to info?
May 12th, 2011 2:38pm
you are getting/reading these config params from the table into variables, aren't you?Arthur My Blog
Free Windows Admin Tool Kit Click here and download it now
May 12th, 2011 2:44pm
That is exactly where I am stuck. How do I link a row such as
Configuration Filter
412to512
ConfiguredValue
TARGETDB1
PackagePath
\Package.Connections[CONFIGDB.ssis_configuration].Properties[ServerName]
ConfiguredValueType
String
to a specific user-defined variable (e.g. "targetRDBParent") in the parent package?
I need the steps and/or syntax.
May 12th, 2011 3:35pm
Here you go:
Imports System
Imports System.Collections
Imports System.Data
Imports System.Data.OleDb
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime
Public Class ScriptMain
Public Sub Main()
Try
Dim ht As New Hashtable(20)
Dim c As New OleDbConnection( _
Dts.Connections.Item("Datawarehouse").ConnectionString)
Dim sqlCommand As New OleDbCommand( _
"select ParameterName, ParameterValue from Z_Parameters", c)
c.Open()
Dim sqlResult As OleDbDataReader
sqlResult = sqlCommand.ExecuteReader()
While sqlResult.Read()
If Dts.VariableDispenser.Contains( _
"User::" + sqlResult.GetString(0)) Then
ht.Add(sqlResult.GetString(0), sqlResult.GetString(1))
Dts.VariableDispenser.LockForWrite("User::" + sqlResult.GetString(0))
End If
End While
sqlResult.Close()
Dim vars As Variables
Dts.VariableDispenser.GetVariables(vars)
Dim de As DictionaryEntry
For Each de In ht
vars(de.Key).Value = de.Value
Next
vars.Unlock()
Dts.TaskResult = Dts.Results.Success
Catch ex As Exception
Dim m As String = ex.Message
While Not ex.InnerException Is Nothing
ex = ex.InnerException
m += vbCrLf + ex.Message
End While
Dts.Log(m, 0, Nothing)
Dts.TaskResult = Dts.Results.Failure
End Try
End Sub
End Class
Taken from http://blog.boxedbits.com/archives/8
Arthur My Blog
Free Windows Admin Tool Kit Click here and download it now
May 13th, 2011 10:19am
Many thanks! Will check this out a bit later today...
May 13th, 2011 2:16pm
After looking at the code, I see that it may be an approach that I eventually use, but it is apart from the built-in Microsoft framework described here <http://msdn.microsoft.com/en-us/library/cc671625.aspx> that uses the standard ConfigurationFilter
and PackagePath mechanism. I would still like to understand how to correctly use that built-in mechanism...
Free Windows Admin Tool Kit Click here and download it now
May 13th, 2011 8:44pm