Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Get parent container name?


Get parent container name?

Author
Message
amenjonathan
amenjonathan
SSC-Enthusiastic
SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)

Group: General Forum Members
Points: 136 Visits: 434
I've been searching the net for a few hours trying to answer how to get the name of the parent container in a script. So far I've come up with I think two pieces to the puzzle, but can't put them together.

So I've got the parent container GUID variable System:TonguearentContainerGUID which returns a string. I've also got a class in Dts called DtsContainer. Does anyone know how to instantiate a copy of this DtsContainer class with the GUID from the variable? I can't find any C# code on this subject. The DtsContainer does contain an ID attribute, but it's read only.

Any help would be greatly appreciated!

Edit: Here's a link to the DtsContainer class on technet. Also I'm using 2008 R2.

-------------------------------------------------------------------------------------------------
My SQL Server Blog
Daniel Bowlin
Daniel Bowlin
SSCrazy
SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)

Group: General Forum Members
Points: 2954 Visits: 2629
I don't know if this will work for you. SSIS has a system variable called Source Name that is the name of the container. Can you just pass that to your script task as a read only variable input?
amenjonathan
amenjonathan
SSC-Enthusiastic
SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)

Group: General Forum Members
Points: 136 Visits: 434
I'm currently using System::SourceName to capture the failing task name in OnError. Unfortunately it is not available outside of the event handlers, and also does not capture the name of the container.

If I could get the current ssis app or package object, I could loop through the containers... I think like this:

List<DtsContainer> conContainers = new List<DtsContainer>();
conContainers = (IDTSSequence)package

But I'm not sure how to get the active package object of the package class. I don't want to create anything; I just want to read the .name off the current container object.

Edit: I'm just trying to do something like this:

string strContainerName = DtsContainer.Name; //where DtsContainer is the parent container

-------------------------------------------------------------------------------------------------
My SQL Server Blog
amenjonathan
amenjonathan
SSC-Enthusiastic
SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)

Group: General Forum Members
Points: 136 Visits: 434
Upon further research I've found someone stating the SSIS framework doesn't allow access to the current active package, so my dream of getting the container name via an active object is pretty much out of the question at this point.

I did see something interesting where a guy grabbed all the containers and their names from the pre-execute event handler at the package level. That seems like it could work. I have the GUID. I just need to translate it into a name!

-------------------------------------------------------------------------------------------------
My SQL Server Blog
Daniel Bowlin
Daniel Bowlin
SSCrazy
SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)

Group: General Forum Members
Points: 2954 Visits: 2629
If the source name is not available outside the event handlers, why not create a handler in the On Pre Execute with a script task to take the source name and set it to a user variable and then use the user variable elsewhere.
amenjonathan
amenjonathan
SSC-Enthusiastic
SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)

Group: General Forum Members
Points: 136 Visits: 434
That is definitely an option. The only thing I didn't like about that option is I'm also going to be using this package as a template, and I don't want people on our team to forget to put that task in the pre-execute handler.

I opted with just adding a hardcoded piece to our log start variables script task. Not even remotely happy with it, but at least it's in an obvious place for our template.

-------------------------------------------------------------------------------------------------
My SQL Server Blog
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search