DTS - How do I create and reference a global variable?

  • Hi,

    I've created a DTS package which imports data into 21 tables and I have set up "Execute SQL Tasks" to record and e-mail any failure on any individual table.

    I would like to build a text message to include in one single e-mail when the package has attempted all table updates.

    I.e. on failure @@GlobalVar = @@GlobalVar + 'Table xyz failed'

    Can anyone assist please.

    Regards,

    Ian


    Kindest Regards,

    Ian Smith

  • Try this syntax...

     DTSGlobalVariables("myGV_Name").Value = myGV_Value

  • In addition, you will need to declare the Global Variable(GV), either in your code or at the DTS package level.  I would suggest declaring it at the package level. 

    Open the Package in design view, right click to get to Package Properties, then the second tab in called 'Global Variables' to declare your String variable. 

    Then, as Bellis (above) notes, use code in your steps to set the value of the GV.   hth

  • Thank you to both of you,

    Had tried code however I was unable to reference global variable in EXEC SQL tasks.

    Seemed a choice between doing everything in code or everything in SQL so (already invested in SQL) I took the SQL route, using one of my stored procedures and a table.field as my "global variable".

    Each step adds to "global variable" according to success or failure and at the end (with a few Char(13)s) I dump the field into a single email listing progress and results.

    I normally do prefer code so I must get into DTS code sometime.

    Again, many thanks.

     


    Kindest Regards,

    Ian Smith

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

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