Advertisement
Guest User

Untitled

a guest
Jul 29th, 2015
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. SELECT
  2. ja.job_id,
  3. j.name AS job_name,
  4. ja.start_execution_date,
  5. ISNULL(last_executed_step_id,0)+1 AS current_executed_step_id,
  6. Js.step_name
  7. FROM msdb.dbo.sysjobactivity ja
  8. LEFT JOIN msdb.dbo.sysjobhistory jh
  9. ON ja.job_history_id = jh.instance_id
  10. JOIN msdb.dbo.sysjobs j
  11. ON ja.job_id = j.job_id
  12. JOIN msdb.dbo.sysjobsteps js
  13. ON ja.job_id = js.job_id
  14. AND ISNULL(ja.last_executed_step_id,0)+1 = js.step_id
  15. WHERE ja.session_id = (SELECT TOP 1 session_id FROM msdb.dbo.syssessions ORDER BY agent_start_date DESC)
  16. AND start_execution_date is not null
  17. AND stop_execution_date is null;
  18.  
  19. --EXEC msdb.dbo.sp_stop_job N'JobName'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement