Thursday, 19 September 2013

SQL Server Script : Check SQL Server Database Status using SQL query

You can check Database Status using SQL query.

Below are the possible status of database.
  • ONLINE : Database is available for access.
  • RESTORING : Primary file group and secondary files are being restored.
  • RECOVERING : Database is being recovered.
  • RECOVERY PENDING : Resource-related error occurred during recovery.
  • OFFLINE : Database is unavailable to access.
  • SUSPECT : One or many primary file group is suspect and may be damaged.
  • EMERGENCY : User has changed the database and set the status to EMERGENCY.

Here is query for this.


SELECT DATABASEPROPERTYEX('NorthWind', 'Status') Database_Status

SELECT state_desc Database_Status FROM sys.databases WHERE name = 'NorthWind'

Output :

Check SQL Server Database Status using SQL query
(To view original image , click on image)

This is very useful SQL Server Scripts. Visit this link for more useful SQL Server Scripts. Click Here...


1 comment:

  1. for effective administrative performance on sql server seek advice from
    sql server programmer
    .for further information take the help of sql server notes.

    ReplyDelete