Fragen Sie die Job-Aktivitätstabelle nach einem Lauf, der gestartet, aber nicht beendet wurde:
SELECT
DATEDIFF(SECOND, aj.start_execution_date, GETDATE()) AS Seconds
FROM msdb..sysjobactivity aj
JOIN msdb..sysjobs sj ON sj.job_id = aj.job_id
WHERE aj.stop_execution_date IS NULL
AND aj.start_execution_date IS NOT NULL
AND sj.name = 'JobX';Die NOT EXISTS-Bedingung verhindert, dass ältere Sessions gezählt werden.