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.
--Main Scripts SQLCMD.EXE -S <servername> -E -dmsdb -h-1 -iQueryToRun_MSDB.sql -o output.txt --QueryToRun_MSDB.sql (For Disabling SQL Jobs) EXEC sp_update_job @job_name=N'S_AAAA',@enabled=0 --QueryToRun_MSDB.sql (For Enabling SQL Jobs Schedule) EXEC sp_update_jobschedule @job_name = N'S_AAAA', @name =N'SCH_AAAA1' ,@enabled = 1 --Use @enabled = 1 for enabling and @enabled = 0 for disabling.
You can visit MSDN for more learning on this storeprocedure.
Published under: General Technology Tips · · · ·