[fix] - RESTORE cannot process database

Wikitechy | 1564 Views | sql server | 09 Jun 2016

 

Scenario : 

  • To restore a DB via a .bak file using SSMS window as follows:


Error :

  • Restore failed for Server 'database_name'. (Microsoft.SqlServer.Smo)System.Data.SqlClient.SqlError: RESTORE cannot process database 'database_name' because it is in use by this session. It is recommended that the master database be used when performing this operation. Microsoft.SqlServer.Smo)


Reason for the error :

  1. The DB for restore is in use by other user.
  2. The database may be set as default database with respect to an user login.

Fix 1 :

  • Verify the activity monitor to close all open connections to the DB
  • Kill all idle connections from other users. 
  • Note: Both the above process must be performed with critical care in the production servers.

Fix 2 : 

  • Change the default DB for the user from current DB to master DB.

Applies to sqlserver version : 

  • SQL Server 1.1 (16 bit)
  • SQL Server 4.2A (16 bit)
  • SQL Server 4.2B (16 bit)
  • SQL Server 4.21a
  • SQL Server 6.0
  • SQL Server 6.5
  • SQL Server 7.0
  • SQL Server 7.0 OLAP Tools
  • SQL Server 2000
  • SQL Server 2000 64-bit Edition
  • SQL Server 2005
  • SQL Server 2008
  • Azure SQL DB
  • SQL Server 2008 R2
  • SQL Server 2012
  • SQL Server 2014
  • SQL Server 2016

Related Error Tags :

  • Unable to restore Database, Database is in use by session
  • c# - Error :RESTORE cannot process database
  • Can't restore SQL 2008 backup - error that the database is in use
  • Bug: RESTORE cannot process database 'database_name'
  • C# - Database Restoration Fails With An Error
  • SQL: Errors related to restore database
  • sql server - Error in restore database
  • RESTORE cannot process database 'database_name'
  • Can't restore SQL 2008 backup - error



Workshop

Bug Bounty
IOT Hackathon
Webinar

Join our Community

Advertise