August 18, 2005 at 9:31 am
I have a common stored procedure that is called from any number of Jobs and I'm looking to determine if theres any way that the stored proc using SQL can determine the ID of the job which executed it so I can go out to MSDB..sysjobs and get the job name and insert it into any error messages that might come out.
thks
August 18, 2005 at 9:58 am
How about going the other way around.. create a table, add column CallingJob
Then when you start the job, first update that column, then the proc will be able to access that info.
August 19, 2005 at 2:45 am
You could alter your stored procedure to accept the Job ID uniqueidentifier as a parameter.
Then in the job that calls the stored procedure, add the SQL Agent token [JOBID]. Then your stored procedure can use the resulting id to get the job name.
Check out Books Online for the SQL Agent tokens that are available. There is also a good article available at http://www.sqldev.net
--------------------
Colt 45 - the original point and click interface
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply