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 Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Wednesday, April 16, 2014 11:21 AM
Points: 293, Visits: 499
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


Right there with Babe

Right there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with Babe

Group: General Forum Members
Last Login: Monday, April 14, 2014 11:49 AM
Points: 739, Visits: 2,470
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;





The SQL Guy @ blogspot

@SeanPearceSQL

About Me
Post #1378701
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse