I needed to determine if a database was being restored or not. The easy way is to determine the status of the database using the following script:
select [name], databasepropertyex([name], 'Status') as Status
from sysdatabases
where [name] = 'DatabaseName'
If the database is being restored, then the status will state: RESTORING
Other valid values for Status are:
ONLINE = Database is available for query.
OFFLINE = Database was explicitly taken offline.
RESTORING = Database is being restored.
RECOVERING = Database is recovering and not yet ready for queries.
SUSPECT = Database did not recover.
EMERGENCY = Database is in an emergency, read-only state. Access is restricted to sysadmin members
No comments:
Post a Comment
Remember, if you want me to respond to your comment, then you need to use a Google/OpenID account to leave the comment.