View Recovery State

Posted on 2011-10-07
Last Modified: 2012-06-27
I know in SQL 2008 I can do a right click on the database and navigate to where I can view the recovery state

Is there a script that I can run that lets me see that?  I can set with the script below...I want to see it with a script

alter database AdventureWorks
set recovery simple;
Question by:lrbrister
    LVL 15

    Expert Comment

    Select state_desc, State FROM sys.databases

    Select status
    FROM sysdatabases

    1 = autoclose; set with ALTER DATABASE.
    4 = select into/bulkcopy; set with ALTER DATABASE RECOVERY.
    8 = trunc. log on chkpt; set with ALTER DATABASE RECOVERY.
    16 = torn page detection, set with ALTER DATABASE.
    32 = loading.
    64 = pre recovery.
    128 = recovering.
    256 = not recovered.
    512 = offline; set with ALTER DATABASE.
    1024 = read only; set with ALTER DATABASE.
    2048 = dbo use only; set with ALTER DATABASE RESTRICTED_USER.
    4096 = single user; set with ALTER DATABASE.
    32768 = emergency mode.
    4194304 = autoshrink , set with ALTER DATABASE.
    1073741824 = cleanly shutdown.

    LVL 75

    Accepted Solution

    SELECT DATABASEPROPERTYEX('YourDatabaseNameGoesHere', 'Recovery')
    LVL 15

    Expert Comment

    Right click Database, Properties -> Option -> State
    LVL 75

    Assisted Solution

    by:Anthony Perkins
    You can also do (just correct the obvious typo in xSELECT):
    xSELECT recovery_model, recovery_model_desc
    FROM sys.databases
    WHERE name = 'YourDatabaseNameGoesHere'

    Author Closing Comment

    Exactly what I wanted on both answers

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
    Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
    This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
    Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now