Reputation: 10209
I'm restoring a database from backups in Sql Server Management Studio.
This is done in 2 states.
How can I identify when a database is in restore state (between 1 and 2)? I want to make an sql script that tell me that, if it's possible.
Note: I know i can see that from Sql Server Management Studio -> Activity Monitor.
Upvotes: 1
Views: 402
Reputation: 10466
As @SchmitzIT has pointed out in his answer (+1), and as specified in MSDN, this data can be retrieved via querying sys.databases
:
SELECT *
FROM sys.databases
WHERE state = 1
If your DB is hanging in RESTORING
state, you can release it using:
RESTORE DATABASE 'DATABASE_NAME' WITH RECOVERY
Upvotes: 2