Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

DTS Global Variables

Posted on 2009-07-06
7
Medium Priority
?
457 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 1600 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
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
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 400 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

609 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