Setting a global variable from two variables

  • I'm trying to use a Dynamic Properties Task to set a global variable value using two other concatonated global variables, and not having much luck, but I think I'm missing something simple.

    I looked at using Global Variable as the source for the dynamic update, but it only seems to allow one variable (as does the main gv assignment tab in the package properties); I can't concatonate there. So, I'm using a query to concatonate them, but get various errors, or no assignment in the refresh/preview box.

    I've set up three variables as strings (@FilePath, @FileName, @Destination). Then in the Dynamic Task, used the query below to set the @Destination variable, which in turn is used as the destination for my text file. Trying first with the 'Set' statements commented out, I get no error, but the values assigned from the properties tab are not picked up for the two concatonated variables. If I run the package, I get a file as named in the @Destination properties tab. The Dynamic Task seems ignored.

    Declare @FilePath varchar(256)

    Declare @FileName varchar(256)

    --Set @FilePath = 'D:\dts\'

    --Set @FileName = 'text4.txt'

    Select @FilePath + @FileName

    If I un-comment the 'Set' statements, I get a "parameter is incorrect" statement. The sytax works fine in query analyzer.

    What am I missing? Any help much appreciated!

    Brad

  • Use an ActiveX Script task to concatenate into the 3rd DTS variable:

     

    Function Main()

     'Concatenate DTS global variables "FilePath" and "FileName" into Destination

     DTSGlobalVariables("Destination") = DTSGlobalVariables("FilePath") & DTSGlobalVariables("FileName")

     Main = DTSTaskExecResult_Success

    End Function

  • Excellent.

    Thank you.

Viewing 3 posts - 1 through 2 (of 2 total)

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