0

For maintenance tasks on my LogShipped environment I run T-SQL script to disable the copy/restore agent job for the duration of maintenance and then enable when done. When I enable the jobs via TSQL it seems the schedule hangs (at last run date) and does not execute future schedules and LS DBs fall out of sync. Restarting the SQL Agent & manual start of the job resolves the issues ok.

SQL Server 2016 SP1. Using msdb..sysjobs to disable/enable the job and msdb..sysjobschedule to disable/enable the schedule

Anyone any ideas?

0

Are you using this correct way for disable jobs?

USE msdb ;
GO
EXEC dbo.sp_update_job
@job_name = N'NameOgYourJob',
@enabled = 0 ;
GO

You don't have to update with update statement, it's describe HERE and HERE

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.