How can I track database state changes

jingwen li 1 Reputation point

For example, the database can be changed from ONLINE to RECOVERING/RESTORING/OFFLINE, I want to tracking this status change.

Azure SQL Database
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Alberto Morillo 32,806 Reputation points MVP

    The following dynamic management view DMV gives you the state of the database:

    SELECT * FROM sys.dm_database_replica_states

    See the database_state_desc column in the result.

    In addition, the sys.databases DMV provides that information.

    SELECT name, user_access_desc, is_read_only, state_desc, recovery_model_desc
    FROM sys.databases;