Refresh the content of variables


  • Hi all,

    i have 4 variables:

    Variable01: @[User::Variable01] = (DT_STR,4,1252)YEAR(GETDATE()) + "-" + (MONTH(GETDATE()) < 10 ? "0" + (DT_STR,2,1252)MONTH(GETDATE()) : (DT_STR,2,1252)MONTH(GETDATE()))

    Variable02: @[User::Variable02] =(MONTH(GETDATE()) < 10 ? "0" + (DT_STR,2,1252)MONTH(GETDATE()) : (DT_STR,2,1252)MONTH(GETDATE()))

    CurrentFileString01: @[User::CurrentFileString01]= "\\" + "\\" + "server01" +"\\" + "s$" +"\\" + "Backup" + "\\" + "PC" + "\\"  + @[User::Variable01] + ".txt" 

    CurrentFileString02: @[User::CurrentFileString02]= "\\" + "\\" + "server01" +"\\" + "s$" +"\\" + "Backup" + "\\" + "PC" + "\\"  + "AgentSessions_" + @[User::Variable02]  + ".txt" 

    When one month ends (for example July ends and August begins) the variables get not the new content.

    On 31.07.2013 the content was:

    Variable01: 2013-07

    Variable02: 07

    CurrentFileString01: \\server01\s$\Backup\PC\2013-07.txt

    CurrentFileString02: \\server01\s$\Backup\PC\AgentSessions_07.txt

    On 01.08.2013 the content is the same. The variables check not again. Only if i open the expression and press "evauate expression" i get the right values:

    Variable01: 2013-08

    Variable02: 08

    CurrentFileString01: \\server01\s$\Backup\PC\2013-08.txt

    CurrentFileString02: \\server01\s$\Backup\PC\AgentSessions_08.txt

    How can i turn the package to check automaticly the expression?

    I tryed the option "evaluate as expression", but after i do this to more then 2 variables, VisualStudio2008 freeze for more than 15 minutes and after every change in the project it will freeze again. This behavior i have on 2 different maschines: Vista32Bit and Win2008 Server.

    Thx, hope someone could help me.

    • Edited by JumpersAldy Thursday, August 01, 2013 8:22 AM
    Thursday, August 01, 2013 8:13 AM

All replies

  • There's no need to do this. SSIS will automatically refresh the values when the package runs.
    The values you see during design time are just for example purposes.

    MCSE SQL Server 2012 - Please mark posts as answered where appropriate.

    Thursday, August 01, 2013 8:54 AM
  • the last months it did not work, maybe the error is someplace else?

    I have a directoy with many txt files. The format change every new month.
    File 1: 2013-08.txt (yyyy-mm.txt)
    File 2: AgentSessions_08.txt (AgentSessions_mm.txt)

    With the variables i want to catch the right file of the current month in preparation for a "move files" job.
    In this job i use CurrentFileString01 and CurrentFileString02 to catch the right files. In the "file system task" i mark "isSourcePathVariable" as true and SourceVariable as "User::CurrentFileString01"

    Now we have August. When i start the filesystemtask  not "\\server01\s$\Backup\PC\2013-08.txt" is taking.
    The job still move the file from July "\\server01\s$\Backup\PC\2013-07.txt"
    But if i open the expression and press "evauate expression" i get the right values and the right file is taking.

    Note: at this time "evaluate as expression" in the variable properties is false because of freezing.

    • Edited by JumpersAldy Thursday, August 01, 2013 10:39 AM
    Thursday, August 01, 2013 10:38 AM