• vsamantha35 (9/26/2016)


    IF @RoleDesc = 'PRIMARY'

    BEGIN

    ALTER AVAILABILITY GROUP [MytestAG] FAILOVER;

    END

    Here you are telling the AG to failover if it's the primary. Failover should be initiated from the secondary replica. So you should setup your job on the secondary, and have that do the failover in the event that @RoleDesc = 'SECONDARY'



    Shamless self promotion - read my blog http://sirsql.net