Re-using scripts between packages in a solution

  • Hi,

    For our project, we need to set the value of variables at run-time, for which we're using a Script Task. Since the same script has to be executed for all packages in the solution, I was wondering if scripts could be re-used between packages. MSDN says I might have to develop a custom component, but since I'm no programmer, I was wondering if there was any other workaround for achieving this.

    Googling got me to Script Task Plus (http://www.cozyroc.com/ssis/script-task), but I would not be able to use this since our clients, being typical clients, would not agree to this. 🙂

    Kindly let me know if there is any solution for this.

    Regards,

    Guru

  • This is typicially handled with an SSIS package template. You create one package and then use it as the basis for other packages. Other than that not really a way..

    CEWII

  • The other way to do this ought to be global procedures. For example, in the past when I did everything in VB I'd have a module containing common functions, declared Public, and could use them in every other module.

    But this does not seem to work in SSIS! Tasks do not seem to be able to see other tasks' Public names, and

    Public Function Whatever() as String

    ....

    End Function

    is only visible in its own task.

    I suspect that the answer is to use Imports in each script to make your code module visible - but have no idea what the Imports string would be!

    Does anyone else know?

  • Based on the object model and how the script is instantiated I would say you can't.

    CEWII

  • Elliott, even if there's no way to use functions from another SSIS task, there must be some way to use things declared in a separate module, else how would all the VB.NET classes be accessible?

    I can't believe there's no way to do it at all; that would put SSIS 2008 back before subroutines were invented in the 1950's 😛

    I found a reference on a Microsoft site saying you could solve this problem by creating a managed DLL library. Presumably you could then write your common functions as methods, to reference and use in your tasks, perhaps through an Imports statement. But it gave no indication of how to do this. Can anyone here tell us how? Preferably using the version of Visual Studio that comes with SSIS 2008. Ideally with a simple example!

  • With the tools AS PROVIDED you can't access anything in other scripts or containers.

    With that said you could maybe do it with either a custom control-flow or data-flow task.

    As far as exactly how.. I can't answer that.

    CEWII

  • Unless I'm misunderstanding the requirement, seems BOL outlines how to do this here.

    Basically write your routines/methods you want to use across different packages into a dll (must be signed) and then in the package, make a reference to the dll from VSTA (ie the script editor) and for runtime, put your signed dll in the GAC.

    HTH,

    Steve.

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply