#JustLearned 5 Disabling/Enabling SQL Jobs or Job schedule from remote computer

Here is the way to disbale/enable the SQL Jobs or its schedule from remote computer, The script is usning windows authentication and querying the MSDB database.

01.--Main Scripts
02.SQLCMD.EXE -S <servername> -E -dmsdb -h-1  -iQueryToRun_MSDB.sql -o output.txt
04.--QueryToRun_MSDB.sql (For Disabling SQL Jobs)
05.EXEC sp_update_job @job_name=N'S_AAAA',@enabled=0
07.--QueryToRun_MSDB.sql (For Enabling SQL Jobs Schedule)
08.EXEC sp_update_jobschedule @job_name = N'S_AAAA', @name =N'SCH_AAAA1' ,@enabled = 1
11.--Use @enabled  = 1 for enabling and @enabled  = 0 for disabling.

You can visit MSDN for more learning on this storeprocedure.

This site uses Akismet to reduce spam. Learn how your comment data is processed.