Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Job Instance ID Expand / Collapse
Author
Message
Posted Friday, October 26, 2012 8:25 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Tuesday, May 14, 2013 9:52 AM
Points: 187, Visits: 332
Does anyone know if there is a function [like getdate()] that you can use to get the Job's instance ID, if the stored proc is running under a Job? The only way I know would be to do a search on the Job and Max(instance_ID).
Post #1377624
Posted Tuesday, October 30, 2012 5:33 AM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Today @ 7:05 AM
Points: 350, Visits: 1,334
This code will get the value when run in a job.

DECLARE @MaxID INT;

SELECT @MaxID = MAX(instance_id)
FROM [msdb].[dbo].[sysjobhistory]
WHERE job_id = CONVERT(uniqueidentifier, $(ESCAPE_NONE(JOBID)))
AND step_id = 1;



http://thesqlguy.blogspot.com/
Post #1378701
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse