Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save JavierCanon/288e92099fc4091d5db757977445cf1b to your computer and use it in GitHub Desktop.

Select an option

Save JavierCanon/288e92099fc4091d5db757977445cf1b to your computer and use it in GitHub Desktop.
How to Fix Error "Recovery Pending State" in SQL Server Database or Express or Localdb ?

How to Fix Error "Recovery Pending State" in SQL Server Database or Express or Localdb ?

Reasons behind Recovery Pending State in SQL Server

Some of the reasons causing such an issue are:

  • The database didn’t shut down properly and there is at least one uncommitted transaction active during the shutdown, resulting in deletion of the active transaction log file.
  • User tried moving the log files to a new drive to overcome server performance issues, but ended up corrupting the log files in the process.
  • Database Recovery cannot be initiated due to insufficient memory space or disk storage.

Methods to Fix Recovery Pending in SQL Server Database Error

1

ALTER DATABASE [DBName] SET EMERGENCY; GO ALTER DATABASE [DBName] set single_user GO DBCC CHECKDB ([DBName], REPAIR_ALLOW_DATA_LOSS) WITH ALL_ERRORMSGS; GO ALTER DATABASE [DBName] set multi_user GO

2

ALTER DATABASE [DBName] SET EMERGENCY; ALTER DATABASE [DBName] set multi_user EXEC sp_detach_db '[DBName]' EXEC sp_attach_single_file_db @DBName = '[DBName]', @physname = N'[mdf path]'

REFERENCES

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment