SQL Repository
  • Home
  • Articles
    • MS SQL DBA
    • SSIS
    • SSRS
    • T-SQL
  • Code Snippets
    • MS SQL DBA
    • SSIS
    • SSRS
    • T-SQL
  • Interview Questions
    • MS SQL DBA
    • SSIS
    • SSRS
    • T-SQL
  • How To
    • MS SQL DBA
    • SSIS
    • SSRS
    • T-SQL
  • Contact





Database stuck in “Restoring” state

On 15 Sep, 2015
MS SQL DBA
By : Charith Silva
With 2 Comments
Views : 10224

Earlier today I was experiencing an issue with one of our databases called SALES_DB is in Restoring state. I tried to run below ALTER DATABASE commands on the database to set it in online state but it throws the following error.

1
2
ALTER DATABASE SALES_DB SET OFFLINE WITH ROLLBACK IMMEDIATE
ALTER DATABASE SALES_DB SET ONLINE WITH ROLLBACK IMMEDIATE

ALTER DATABASE is not permitted while a database is in the Restoring state.

 

The database seems to be stuck in RECOVERING state forever. Somehow database restore operation has hung or fails to complete, leaving the database inaccessible in a restoring state, usually this is because the database log is missing or corrupt.

 

1. First check .mdf and .ldf  files are exist.

2. Check data and log drives are online and available.

3. Try to stopping and restarting the SQL service.

4. If nothing works you can use below code to recover your database;

 

1
2
3
4
5
USE master;
 
GO
 
RESTORE DATABASE SALES_DB WITH RECOVERY;

 

As soon as successfully restored  the database take full backup.

 

 

Share this:

  • Click to share on Twitter (Opens in new window)
  • Click to share on Facebook (Opens in new window)
  • Click to share on Google+ (Opens in new window)

Related



Previous Post Next Post 

About The Author

Charith Silva

Charith Silva is a Microsoft certified SQL Server developer and database administrator who was graduated at Buckinghamshire New university in the UK. His career was started in 1998, primarily into Web application development, and later diversified into database development. He has got a vast experience in SQL Server database development, Database administration and Business Intelligence development. He believes that sharing the knowledge is key to the success.


Number of Posts : 87
All Posts by : Charith Silva

Comments ( 2 )

  • G@g.com'

    Neil Sep 17 , 2015 at 8:45 pm / Reply

    I don’t think I’d advise step three, restarting the services can cause corruption and put the database into suspect mode, I’ve experienced this twice with junior DBA’S panicing and restarting the services

  • johnsonwelch2@gmail.com'

    johnson Welch Sep 07 , 2016 at 2:55 pm / Reply

    Great stuff thanks for sharing ! The SQL Server Databases Stuck in Restoring State is beginning to clear up. As i found another helpful post for the same see here: https://madhivanan.wordpress.com/2016/09/06/issue-in-recovering-a-database-that-is-in-the-restoring-state-reference/


Leave a Comment

Click here to cancel reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">





  • Popular
  • Recent
  • Database stuck in “Restoring” state

    10224 views
  • Script to Check TempDB Speed

    3061 views
  • Find the modified date of SQL Server Agents Jobs

    3045 views
  • Log shipping Alerts failing to send emails

    2332 views
  • PING all the Linked Servers and get a status report

    2273 views
  • Moving the tempdb database

    27 Jan, 2016
  • Script to Check TempDB Speed

    14 Jan, 2016
  • SQL Server buffer pool

    05 Nov, 2015
  • Log shipping Alerts failing to send emails

    04 Nov, 2015
  • View queries waiting for memory grant

    21 Oct, 2015

Useful links

  • Books Online for SQL Server 2012
  • Developer Reference for SQL Server 2014
  • Download SQL Server
  • Installation for SQL Server 2012
  • Microsoft Virtual Academy
  • SQL Server Online Training
  • Transact-SQL Reference
  • Tutorials for SQL Server 2012

Tags

.CSV 70-461 AdventureWorks 2012 ALL ANY CAST Chinook Database Code Snippet CONVERT CTE dataset datasource Dates DATETIME divide by zero Duplicates Exam EXCEPT expressions FORMAT IF Import Indexes INTERSECT Jobs NULLIF REBUILD Recursive CTE REORGANIZE ROW_NUMBER() Schedules Sequence SOME sp_stop_job SQL Server 2012 SQL Server Agent SSIS SSRS T-SQL Tally Table T_SQL UAC Permissions Error UNION UNION ALL

Recent Comments

  • Rudnei Silva on Log shipping Alerts failing to send emails
  • johnson Welch on Database stuck in “Restoring” state
  • Neil on Database stuck in “Restoring” state
  • Mark Gribler on MS SQL Database Administrator Interview Questions – Part 4

Google Analytics Stats

Latest Tweets:

  • 4 years ago Attended @SQLSatMcr yesterday - it was amazing! Roll on @sqlsatcambs! Won some Beats Headphones courtesy of @SQLDBApros - thanks guys! :)
  • 4 years ago Looking forward to attending @SQLSatMcr - its too far off though!!!
  • 4 years ago Simple Post: WhoIsActive SPROC: http://t.co/LZvQUaeapK
  • 4 years ago POST: Index REBUILD or Index REORGANIZE: http://t.co/h3L0N37vw4
  • 4 years ago How to Ping all Linked Servers: http://t.co/Q2QxusrKjO
  • 4 years ago For beginners - T-SQL Divide by Zero Error: http://t.co/BBhgoH5hK9

© Copyright 2015 SQL Repository. All Rights Reserved by SQL Repository