Database Recovery

  • Is there any query in SQL Server 2005 which gives the status of database, if the database is showing recovery (after we start SQL Server Service).

    ex: select [name], [is_read_only] from sys.databases

    resultset:

    [name] [is_read_only]

    DB1 0

    DB2 0

    DB3 1

    DB4 0

    Just like this.

    Thanks,

    Sri.

  • Have you read the article on sys.databases in Books Online? You really should. 🙂

    Anyway, here's the query:

    select[name]

    ,state_desc

    fromsys.databases

    ...or if you want a 1 for every database in recovery, and a 0 for every other state:

    select[name]

    ,is_inrecovery

    = case[state]

    when2

    then1

    else0

    end

    fromsys.databases

    ML

    ---
    Matija Lah, SQL Server MVP
    http://milambda.blogspot.com

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply