Solved

DTS Global Variables

Posted on 2009-07-06
7
408 Views
Last Modified: 2013-11-30
Hi all,

I have 2 DTS global variables. POStart and POEnd. At the beginning of my DTS package, POStart is assigned the following value through an activeX script:

DTSGlobalVariables("POStart").Value = DateDiff("n", Now, DTSGlobalVariables("POEnd").Value)

POEnd is assigned a value at the end of the DTS package, through another ActiveX script:

DTSGlobalVariables("POEnd").Value = Now()

Essentially, POStart is used to determine when the last time the package was successfuly run.
My problem is that when run as a SQL Agent job, the POEnd variable is not being passed on, job to job. It is holding the value that is stored when I last manually ran the DTS package in design mode.

Any ideas guys?
0
Comment
Question by:FMabey
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 17

Accepted Solution

by:
dbaSQL earned 400 total points
Comment Utility
>>My problem is that when run as a SQL Agent job, the POEnd variable is not being passed on, job to job.

Surely there is a better way to handle it, but if it's not being saved from job to job, why don't you just write it to a working table, upon each execution?  then, next time the job runs, you could blow out the existing value and replace it with what is assigned at the end of the execution, via activex
0
 
LVL 75

Expert Comment

by:Anthony Perkins
Comment Utility
>>My problem is that when run as a SQL Agent job, the POEnd variable is not being passed on, job to job. It is holding the value that is stored when I last manually ran the DTS package in design mode.<<
What did you expect, that is how variables in any language are supposed to work.  They are transitory in nature.

Instead of doing that, why don't you look at the Job history,  That contains all the info you meed.
0
 
LVL 3

Author Comment

by:FMabey
Comment Utility
I did think of looking at the job history but I wasn't sure how to pick up the last run date/time for a particular DTS package and then put that into my activex script.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 17

Expert Comment

by:dbaSQL
Comment Utility
ac is right.  i hadn't thought of that

select * from msdb..sysdtssteplog
select * from msdb..sysdtstasklog

see this: http://www.sqlservercentral.com/articles/Administration/managingdtspackageseditingschedulingandviewingpack/890/


Viewing the logs of DTS packages

For debugging purposes, you can log the execution of DTS package. Logging a DTS package can tell a developer the status of each step within the package: the start time, end time, whether it is successful, if not, for what reason, etc. You might notice that developers will not be able to view the package logs once they are taken out of SYSADMIN.

0
 
LVL 75

Assisted Solution

by:Anthony Perkins
Anthony Perkins earned 100 total points
Comment Utility
Actually I was not referring to the DTS Package Log, but rather the SQL Server Agent Job History Log.  I suspect the author is wanting to view past history as well, and that would be impossible if they had no logging setup.

For a start take a look at the sp_help_jobhistory for start and elapsed times.
0
 
LVL 42

Expert Comment

by:EugeneZ
Comment Utility
as per BOL
"A global variable created during design time retains the value it had when the package finished execution, if the package is saved.
However, global variables created dynamically in an ActiveX script have two scopes. If they are created above the Function Main(), they are available to all functions in the script. This is the equivalent to module-level scope. If they are declared within a function, they are available only inside that function. This is equivalent to procedure-level scope."
more
Using Global Variables with DTS Packages
 http://msdn.microsoft.com/en-us/library/aa933470(SQL.80).aspx
also you may try to use
dtsrun utility and pass globalVar values in your sqlagent job
http://msdn.microsoft.com/en-us/library/aa224467(SQL.80).aspx
 
0
 
LVL 3

Author Closing Comment

by:FMabey
Comment Utility
I have selected multiple solutions because I actually used dbaSQL's solution but acperkins solution is what I will proabably end up using in the long term.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now