Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Disable a SQL Agent Job not working

Question: I have a  SQL Server Agent job  in a disabled status. The disabled status is  applied to the Sql Agent Job and the associated schedule.  The problem is I'm logged on as a full administrator onto the Windows Server - and as BUILTIN\Administrator is defined on the SQL Server , but am able to manually override the SQL Agent Job.   

Is there a way to Disable the SQL Agent Job where I'm not able to manually override the job?

Answer:   There is no way to disable a SQL Agent Job where it cannot be run manually. The disabled option on a SQL Agent Job  stops the job running as a SQL Agent scheduled job.   I've specified SQL Agent Job because if another schedule  tool such as Autosys is used and triggers a script - than the SQL Agent job will be executed .

For example if using SMO through Powershell and start a disabled SQL Agent job in the context of an ID with suitable privileges , then the job will run 

[Microsoft.SqlServer.Management.Smo.Agent.Job]$job = ($sqlServer.JobServer.Jobs | ? { $_.Name -eq 'MySQLAgentJob' });

$job.Start();

There are certain strategies you could apply :

1) Review access to the elevated ID privilege

2) Delete the Job 

3) Amend in some way for the job to fail 

Read more on managing SQL Agent 

List enabled status of SQL Server Agent Jobs

How to check if SQL Server Agent is running using t-sql

How to schedule a SQL Server Agent Job to execute once a year ...



This post first appeared on SQLSERVER-DBA.com, please read the originial post: here

Share the post

Disable a SQL Agent Job not working

×

Subscribe to Sqlserver-dba.com

Get updates delivered right to your inbox!

Thank you for your subscription

×