dbTalk Databases Forums  

Job ID, Step Id, and Task ID

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Job ID, Step Id, and Task ID in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
David N
 
Posts: n/a

Default Job ID, Step Id, and Task ID - 01-21-2004 , 07:22 PM







Hi All,

If I have a stored procedure that is being run by a DTS which is scheduled
to run by SQLSERVERAGENT. From that stored procedure, can I retrieve the
job id, task id, step id of the DTS package?

Thanks.



Reply With Quote
  #2  
Old   
Darren Green
 
Posts: n/a

Default Re: Job ID, Step Id, and Task ID - 01-22-2004 , 02:42 AM






You cannot get the value directly from within the stored procedure, in the
same way that a procedure would no nothing of the VB code module that called
it. You can however do this with global variables and a Dynamic Properties
Task.

To start with change the job step to something like this

Dtsun /S.... /A"JobID":"3":"[JOBID]"

The syntax is probably wrong, but the key point is you can use the [JOBID]
token functionality of a job step and the /A command for DTSRun to set a
global variable to the SQLAgent Job Id.

You now have the JobID in a global variable at run-time.

Next use a Dynamic Properties Task to assign the step and task Id's (not
sure what you mean, as the "real" identifier for a Dts step and task is the
name) to global variables.

To use the global variables just use the parameter functionality of the Exec
SQL Task to pass in the values.

EXEC myProc ? ? ?

The ? is a placeholder, to which you map the global variables in the UI.


--
Darren Green
http://www.sqldts.com



" David N" <dq.ninh (AT) netiq (DOT) com> wrote

Quote:
Hi All,

If I have a stored procedure that is being run by a DTS which is scheduled
to run by SQLSERVERAGENT. From that stored procedure, can I retrieve the
job id, task id, step id of the DTS package?

Thanks.





Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.