I am trying to set up a maintenance job in my SQL Server 2016 database that runs a check to see if one of my secondary nodes is the primary, if it is, I want it to failover to the actual server that is set up to be the primary. I have the check working, but when I try to run the statement ALTER AVAILABILITY GROUP agname FAILOVER
, nothing happens. The statement doesn’t fail, but it also doesn’t start the failover process. What am I doing wrong?
If dbo.fn_hadr_is_primary_replica <> 1
ALTER AVAILABILITY GROUP dbname FAILOVER
expected to fail over from the replica back to the primary, but nothing happens.