DanielLoth / SQLServerJobRunner

MIT License
5 stars 2 forks source link

Support for Availability Groups - jobs could fail when Readable-Secondary is set to Read-Only #7

Closed DaveDustin closed 1 year ago

DaveDustin commented 1 year ago

In JobRunner.AddAgentJob the msdb.dbo.sp_add_jobstep assigns the @database_name value to the target database for the job.

If this job were running on a secondary node where the Readable-Secondary configuration is set to Read-Only instead of All the job will fail because it cannot connect to the database to execute the step.

DanielLoth commented 1 year ago

Fixed. Thanks for pointing this out.