Variable - evaluates to include seconds - every reference it has new value (seconds)

  • In SSIS I have a variable which is evaluated as an expression and it returns seconds (along with date) to name a file.

    I name the file and save it, then around 10 seconds later when the last control flow has finished it sends an email with a link to where that file is stored.

    By that time ~10 seconds have passed so when the variable is referenced again it has a new value for the seconds (or possibly even minutes).

    How can I get my variable to only evaluate once and maintain that same value through the entire execution of the package?

    If my package starts at 8:00:00 AM and ends at 8:01:15 AM I still want that original 8:00:00 AM value to reference later.

  • Quick thought, but I'm not an SSIS expert.

    You could assign the value to your variable through a Script task instead of an expression. That way, you'll keep the same value during the entire execution.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • Yep and that works but feels so wrong 🙂

  • There is an SSIS System Variable called 'StartTime'.

    You may be able to create an Expression which uses this, thus avoiding the need for a Script Task.

    The absence of evidence is not evidence of absence.
    Martin Rees

    You can lead a horse to water, but a pencil must be lead.
    Stan Laurel

  • Phil Parkin (9/5/2014)


    There is an SSIS System Variable called 'StartTime'.

    You may be able to create an Expression which uses this, thus avoiding the need for a Script Task.

    +1

    The system variables are there for exactly this purpose.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

Viewing 5 posts - 1 through 4 (of 4 total)

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