This Error Message Article explains the SQL Server error message “Microsoft SQL Server Management Studio Restore failed for Server “[Server Name]”…Exclusive access could not be obtained because the database is in use.” and details how to fix the underlying problem that caused it to appear.
The action (in this case a restore) cannot be performed on the SQL database. The error indicates that the database is ‘in use’.
In the situation that caused this error, we could not find a reason for the database to be ‘in use’. We stopped all services related to the application (TEKLYNX CENTRAL) that we could find that may have locked the database.
A few possible solutions:
- Use Activity Monitor feature to determine what application is using the database and stop that application (although Activity Monitor can be used with SQL Express it must be loaded using the full SQL installer not SQL Express according to some blog entries)
- Restart the SQL instance services to force users off (this has been tested successfully)
- Use a SQL command to disconnect and roll back any partial connections and put into single user mode
Related Articles: Unable to Restore a SQL Database Because Database ‘In Use’ – KBA-01597-Z6F6R6
Enable or Disable a Service in Windows – KBA-01212-V9N6Y4
Disconnect Database Users with the SET SINGLE_USER SQL Command – KBA-01598-Y7R6C7
Issue Found: Windows 2008R2, running SQL Server 2008R2
Related Link: https://social.msdn.microsoft.com/Forums/sqlserver/en-US/aad41cbb-10cb-4109-9e55-aab048bbeb9d/exclusive-access-could-not-be-obtained-because-the-database-is-in-use?forum=sqldisasterrecovery