Best Practice

  • Good morning. I just have a quick question for you folks. Do you know if when using a Script task in SSIS, is it best practice to create a local variable to hold a value from a variable created at the package or container level, as opposed to just reading directly from the package/container-level variable? For example, out of scenarios A and B below, which is better/best practices?

    A:

    MessageBox.Show(Dts.Variables["strErrorDescription"].Value.ToString());

    B:

    string errDesc = Dts.Variables["strErrorDescription"].Value.ToString();

    MessageBox.Show(errDesc);

    Thanks...Chris

  • I'm accustomed to using the package variable, not a script-local one. But that's habit, not something based on actually comparing efficiency/performance/anything.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • Thanks for the reply.

  • For the sake of readability I use option B. But this is a personal choice.

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

  • OK...thanks.

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

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