Solved

DTS Global Variables

Posted on 2009-07-06
7
429 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
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
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 
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 42

Expert Comment

by:EugeneZ
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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

786 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