Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Get parent container name? Expand / Collapse
Author
Message
Posted Monday, September 16, 2013 12:20 PM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Monday, December 16, 2013 10:42 AM
Points: 96, 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::ParentContainerGUID 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
Post #1495228
Posted Monday, September 16, 2013 12:43 PM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Tuesday, October 7, 2014 2:36 PM
Points: 2,818, Visits: 2,565
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?
Post #1495240
Posted Monday, September 16, 2013 1:24 PM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Monday, December 16, 2013 10:42 AM
Points: 96, 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
Post #1495258
Posted Monday, September 16, 2013 2:14 PM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Monday, December 16, 2013 10:42 AM
Points: 96, 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
Post #1495274
Posted Monday, September 16, 2013 4:17 PM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Tuesday, October 7, 2014 2:36 PM
Points: 2,818, Visits: 2,565
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.
Post #1495320
Posted Tuesday, September 17, 2013 8:15 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Monday, December 16, 2013 10:42 AM
Points: 96, 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
Post #1495521
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse