Solved

DTS Global Variables

Posted on 2009-07-06
7
446 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 17

Accepted Solution

by:
dbaSQL earned 400 total points
ID: 24793398
>>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
ID: 24793534
>>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
ID: 24793547
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 17

Expert Comment

by:dbaSQL
ID: 24793615
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
ID: 24793879
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 43

Expert Comment

by:Eugene Z
ID: 24794280
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
ID: 31600144
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

Is Your DevOps Pipeline Leaking?

Is your CI/CD pipeline a hodge-podge of randomly connected tools? You’ve likely got a tool to fix one problem & then a different tool to fix another, resulting in a cluster of tools with overlapping functionality. Learn how to optimize your pipeline with Gartner's recommendations

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Before we dive into the marketing strategies involved with creating an effective homepage, it’s crucial that EE members know what a homepage is. In essence, a homepage is the introductory, or default page, of a website that typically highlights the …
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Viewers will learn how the fundamental information of how to create a table.

726 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