Create an array of strings in SSIS

By Allen Stoner

If you need to use an array of strings in SSIS it is a little difficult to create it as a variable in the package. It takes defining the package variable as a system.object and calling a script task, either VB or C# (example is VB.NET). In my example I set System:Package name as a ReadOnly variable and User:Categories as ReadWrite, this is also the one defined as the system.object. The sample Main procedure sets the first element of the string array to the package name.

Public Sub Main()
        Dim arr As String()
        ReDim arr(0)

        arr(0) = Dts.Variables("System::PackageName").Value
        Dts.Variables("User::Categories").Value = arr
        Dts.TaskResult = ScriptResults.Success
End Sub

Create an array of strings in SSIS  (2065 Views)