9.0 Database States
9.0 Database States
A SQL Server database state specifies the current running mode of that
database.
There are seven main states in which a SQL Server database can exit.
--Name and state for all databases hosted in the current SQL Server instance
SELECT * FROM sys.databases
[OR]
2: DATABASEPROPERTYX function
The DATABASEPROPERTYX function only allows you to see one element at
a time.
-- can see the Status for the master database by issuing the below query
The primary filegroup is online, although the undo phase of recovery may not have
been completed.
OFFLINE Database is unavailable. A database becomes offline by explicit user action and
remains offline until additional user action is taken.
It make your database unavailable to use and also release any resources (like memory)
it is consuming.
The best part of the offline database is that as the database stay visible in SSMS, we
can bring it back online very quickly.
For example:
1) The database may be taken offline in order to move a file to a new disk. The
database is then brought back online after the move has been completed.
RESTORING One or more files of the primary filegroup are being restored, or one or more
secondary files are being restored offline. The database is unavailable.
Additional action by the user is required to resolve the error and let the recovery
process be completed.
EMERGENCY User has changed the database and set the status to EMERGENCY.
For example, a database marked as suspect can be set to the EMERGENCY state.
This could permit the system administrator read-only access to the database. Only
members of the sysadmin fixed server role can set a database to the EMERGENCY
state.
FROM sys.databases
USE [master]
GO
USE [master]
GO
GUI:
https://www.concurrency.com/blog/november-2018/creating-a-suspect-sql-
database?feed=Blog