Saturday, July 12, 2014

Stop SQL job from commands

Jobs are not stopping when click on stop button of job. so I used follwing command to stop it.



SELECT j.name as jobname
   
              , j.*,ja.*
FROM msdb.dbo.sysjobactivity ja
JOIN msdb.dbo.sysjobs j
    ON ja.job_id = j.job_id
WHERE ja.session_id = (SELECT TOP 1 session_id FROM msdb.dbo.syssessions ORDER BY agent_start_date DESC)
AND start_execution_date is not null
AND stop_execution_date is null;

--sp_who2
--kill -58-  

Where 58 Is SID which I want to stop.

No comments: