none
Is it possible to get task type and task name by code?

    Question

  • let's say i have a ssis like this.

    i want to get the task type and task name in this package. The output will be like this:

    task 1 script task "s1"

    task 2 execute sql task "e1"

    you don't need to do this in this package like the image shows. you can create another APP to do this as long as get the output.

    is that possible?

    Monday, October 14, 2013 4:25 AM

Answers

  • Store the order of the task in an array.

            For i As Integer = 0 To p.PrecedenceConstraints.Count - 1
                'MsgBox(p.PrecedenceConstraints.Item(i).Name)
                Dim taskHost1 As TaskHost = CType(p.PrecedenceConstraints.Item(i).ConstrainedExecutable, TaskHost)
                Dim taskHost2 As TaskHost = CType(p.PrecedenceConstraints.Item(i).PrecedenceExecutable, TaskHost)
                MsgBox("Start Task: " & taskHost2.Name & " -- End Task: " & taskHost1.Name)
            Next


    Regards, RSingh

    • Marked as answer by Andrea Pirlo Friday, October 18, 2013 5:08 AM
    Tuesday, October 15, 2013 8:20 AM

All replies

  • Assuming you're using project deployment model and have deployed the project containing the packages to SSISDB you can use the below query to get task details

    SELECT executable_id,executable_name
    FROM SSISDB.catalog.executables
    WHERE package_name = your package name here
    ORDER BY executable_id

    Monday, October 14, 2013 5:03 AM
  • Try,

            Dim pkg As String = "C:\Users\usernt\Documents\Visual Studio 2005\Projects\Integration Services Project2\Integration Services Project2\package2.dtsx"
            Dim app As Application = New Application()
            Dim p As Package = app.LoadPackage("pkg", Nothing)
            Dim pExecs As Executables = p.Executables
            Dim pExec As Executable
            For Each pExec In pExecs
                Dim taskHost As TaskHost = CType(pExec, TaskHost)
                MsgBox("Type {0}", CType(taskHost.InnerObject.ToString(), MsgBoxStyle))
            Next


    Regards, RSingh

    Monday, October 14, 2013 5:46 AM
  • Try,

            Dim pkg As String = "C:\Users\usernt\Documents\Visual Studio 2005\Projects\Integration Services Project2\Integration Services Project2\package2.dtsx"
            Dim app As Application = New Application()
            Dim p As Package = app.LoadPackage("pkg", Nothing)
            Dim pExecs As Executables = p.Executables
            Dim pExec As Executable
            For Each pExec In pExecs
                Dim taskHost As TaskHost = CType(pExec, TaskHost)
                MsgBox("Type {0}", CType(taskHost.InnerObject.ToString(), MsgBoxStyle))
            Next


    Regards, RSingh

    it got error when ForEachLoop occurs
    Monday, October 14, 2013 6:50 AM
  • Remove "Type {0}",  and try again. Also please post the error message.


    Regards, RSingh

    Monday, October 14, 2013 7:02 AM
  • Remove "Type {0}",  and try again. Also please post the error message.


    Regards, RSingh

    when the pExecs is  ForEachLoop  component ,this convert fails.
    Dim pExecs As Executables = p.Executables

    it perhaps at this time pExecs  is a container, not a simple component.

       
    Monday, October 14, 2013 8:50 AM
  • HELP
    Monday, October 14, 2013 1:56 PM
  • It is working at my end.

            Dim pkg As String = "C:\Users\******\Documents\Visual Studio 2008\Projects\Integration Services Project2\Integration Services Project2\derivecolumn.dtsx"
            Dim app As Application = New Application()
            Dim p As Package = app.LoadPackage(pkg, Nothing)
            Dim pExecs As Executables = p.Executables
            Dim pExec As Executable
            For Each pExec In pExecs
                Dim taskHost As TaskHost = CType(pExec, TaskHost)
                MsgBox(taskHost.Name.ToString() & "---" & taskHost.HostType.ToString())
            Next


    Regards, RSingh

    Monday, October 14, 2013 3:24 PM
  •     For Each pExec In pExecs , the task didn't show up in correct order.
    Tuesday, October 15, 2013 4:56 AM
  • Store the order of the task in an array.

            For i As Integer = 0 To p.PrecedenceConstraints.Count - 1
                'MsgBox(p.PrecedenceConstraints.Item(i).Name)
                Dim taskHost1 As TaskHost = CType(p.PrecedenceConstraints.Item(i).ConstrainedExecutable, TaskHost)
                Dim taskHost2 As TaskHost = CType(p.PrecedenceConstraints.Item(i).PrecedenceExecutable, TaskHost)
                MsgBox("Start Task: " & taskHost2.Name & " -- End Task: " & taskHost1.Name)
            Next


    Regards, RSingh

    • Marked as answer by Andrea Pirlo Friday, October 18, 2013 5:08 AM
    Tuesday, October 15, 2013 8:20 AM