370

SQL Server: Unable to access a database status In recovery

SQL Server: Unable to access a database status In recovery

After restart of a sql server instance one of the databases was no more accessible. SQL Server Maangement studio shows the database status "In recovery (pending)". I tried a lot of suggestions but the only one that worked for me was:

 

  
--grant alter privileges to your user
GRANT ALTER ON DATABASE:: your_database_name TO [your_user]

--change the status of the database
ALTER DATABASE your_database_name SET EMERGENCY

--change the mode of the database
ALTER DATABASE your_database_name SET MULTI_USER

--detach it
EXEC sp_detach_db your_database_name 

--and reatach it
EXEC sp_attach_single_file_db @dbname = your_database_name , 
     @physname = N'path_to_mdf.mdf' 

--now you can use your database again

It's always good practice to create a backup of your database files before you manipulate them.

Comments (0)


This thread has been closed from taking new comments.