?
Solved

DTS Global Variables

Posted on 2009-07-06
7
Medium Priority
?
450 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
Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

 
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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

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…
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
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.
Suggested Courses

777 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