Blog Post

SQL Database Status with sys.databases

,

I was creating a Powershell script for a SQL Server checkout procedure after a reboot , and used  the state_desc column in sys.databases view to report on the database status.

The descriptions , courtesy of BOL are:

ONLINE  - Database is available for access

RESTORING – One or more files are being restored

RECOVERING – Database is being recovered

RECOVERY_PENDING  - SQL Server has encountered a resource-related error during recovery

SUSPECT  - At least the primary filegroup is database suspect and may be damaged

EMERGENCY - User has changed the database and set the status to EMERGENCY

OFFLINE – Database is unavailable

SELECT name, state_desc as Database_status
FROM sys.databases

Author: Jack Vamvas (http://www.sqlserver-dba.com)


Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating