How can we help you today? How can we help you today?
PDinCA
Helps IMMENSELY. Many thanks, Brian. UPDATE Sadly, the join criterion on just job_id gets me the list of every execution, so I revised the query, using my own replacement for DATEDIFF() for the hours calc as I want to be precise, not just have it fire after 3hrs 1min if it starts at, say, 12:59... (Hate DATEDIFF!) Using SELECT TOP 1 ... ORDER BY a.start_execution_date DESC gets me the currently executing Job details. /* Get the JobID for MyJob */ DECLARE @JobId uniqueidentifier SELECT @JobId = job_id FROM msdb..sysjobs WHERE name = '_Quarter Hourly Update Aggregation' /* Define a temp table to hold xp_sqlagent_enum_jobs This xp will tell us which jobs are running */ DECLARE @ExecutionStatus TABLE ( JobID uniqueidentifier PRIMARY KEY -- Job ID , LastRunDate int , LastRunTime int -- Last run date and time , NextRunDate int , NextRunTime int -- Next run date and time , NextRunScheduleID int -- an internal schedule id , RequestedToRun int , RequestSource int , RequestSourceID varchar(128) , running int -- 0 or 1, 1 means the job is executing , CurrentStep int -- which step is running , CurrentRetryAttempt int -- retry attempt , JobState int ----0 = Not idle or suspended, 1 = Executing, 2 = Waiting For Thread, 3 = Between Retries, 4 = Idle, 5 = Suspended, [6 = WaitingForStepToFinish], 7 = PerformingCompletionActions ) INSERT @ExecutionStatus EXEC xp_sqlagent_enum_jobs 1 , '' , @JobId /* Get the number of hours the has been running, if it is running */ SELECT TOP 1 DBA.dbo.udf_GetElapsedHours(a.start_execution_date, GETDATE()) AS RunningHours FROM msdb..sysjobactivity a INNER JOIN @ExecutionStatus s ON s.JobId = a.job_id WHERE s.running = 1 ORDER BY a.start_execution_date DESC Thanks, though, for your original query - wouldn't be anywhere without it. 8) / comments
Helps IMMENSELY. Many thanks, Brian.UPDATE Sadly, the join criterion on just job_id gets me the list of every execution, so I revised the query, using my own replacement for DATEDIFF() for the hour...
0 votes
Withdrawn! Jury's out on the patch - server ground to a halt. Rebooting... UPDATE - ERROR EXCEPTIONS BEING THROW Event Type: Error Event Source: SQL Source Control 3 Event Category: None Event ID: 32 Date: 10/26/2012 Time: 2:13:08 PM User: N/A Computer: XCOUTSIDE1 Description: ng.ErrorReporterBase #6:Not reporting error RedGate.Shared.Utils.OperationCancelledException: Exception of type 'RedGate.Shared.Utils.OperationCancelledException' was thrown. at RedGate.SQLSourceControl.Engine.Cancellables.CancellableOperationStatusConvenienceOverloadsBase.CancelIfCancelled() at RedGate.SQLSourceControl.Engine.Cancellables.MutexedCancellableOperation`1.Invoke() at #eEc.#Qlg.Invoke() at #JLc.#PLc.#Jfb.#EJf() at RedGate.SQLSourceControl.Engine.SmartAssembly.ExceptionReporting.ErrorReporterBase.Do(Action , Predicate`1 , Boolean ) Followed 13 seconds later when changing to another DB Event Type: Error Event Source: SQL Source Control 3 Event Category: None Event ID: 32 Date: 10/26/2012 Time: 2:13:21 PM User: N/A Computer: XCOUTSIDE1 Description: ng.ErrorReporterBase ConfigurableThreadPool thread:Not reporting error RedGate.Shared.Utils.OperationCancelledException: Exception of type 'RedGate.Shared.Utils.OperationCancelledException' was thrown. at RedGate.SQLSourceControl.Engine.Diff.Memoization.ReattachableMemoizer.#uz2b(String , IDatabaseConnection , #1heb , ICancellableOperationStatus , IReadOnlySourceControlServerCallBacks , Action ) at #qlhb.#0heb.#wieb(#L3c , #ZZ7 , #A57 , IDatabasePollingManager , IObjectExplorerStateService , #82Vc , #32Vc , #4Ec , #j3l , Options , #quBb , ICancellableOperationStatus , IReadOnlySourceControlServerCallBacks , Action ) at #GWeb.#VXM.#mYM[#NrPb](Func`2 , ICancellableOperationStatus , IReadOnlySourceControlServerCallBacks , IDifferenceSelector , Action ) at #GWeb.#VXM.#jYM(ICancellableOperationStatus , IReadOnlySourceControlServerCallBacks , IDifferenceSelector ) at #GWeb.#4Ec.#7Jc(ICancellableOperationStatus , IReadOnlySourceControlServerCallBacks , IDifferenceSelector ) at #GWeb.#4Ec.#y2.#QB7b(ICancellableOperationStatus ) at RedGate.SQLSourceControl.Engine.Cancellables.MutexedCancellableOperation`1.#u3.#k5f() at RedGate.SQLSourceControl.Engine.Cancellables.CancellableOperationBase.InvokeWithTracker(String featureUsageKey, Action action) at RedGate.SQLSourceControl.Engine.Cancellables.MutexedCancellableOperation`1.Invoke() at #GWeb.#4Ec.#eqzc(ICancellableOperation`1 ) at #GWeb.#4Ec.#OUe.#hqzc() at RedGate.SQLSourceControl.Engine.SmartAssembly.ExceptionReporting.ErrorReporterBase.Do(Action , Predicate`1 , Boolean ) / comments
Withdrawn! Jury's out on the patch - server ground to a halt. Rebooting...UPDATE - ERROR EXCEPTIONS BEING THROW Event Type: Error Event Source: SQL Source Control 3 Event Category: None Event ID:...
0 votes