SELECT availability_mode_desc , role_desc , replica_server_name , last_redone_time , GETDATE() now , DATEDIFF(ms, last_redone_time, GETDATE()) diffMS FROM ( ( sys.availability_groups AS ag JOIN sys.availability_replicas AS ar ON ag.group_id = ar.group_id ) JOIN sys.dm_hadr_availability_replica_states AS ar_state ON ar.replica_id = ar_state.replica_id ) JOIN sys.dm_hadr_database_replica_states dr_state ON ag.group_id = dr_state.group_id AND dr_state.replica_id = ar_state.replica_id;