Restore MSSQL Error: Database is in use

This is an article on how to do a restore from backup on a database but when you get the error: "... database is in use".
-- SQL Server 2005
EXEC SP_WHO          // details on who is logged in

-- SQL Server 2008
EXEC SP_WHO2         // even more details

-- Run as database owner to see ALL connected processes as well.
  1.  -- SQL Server 2005 
  2.  EXEC SP_WHO          // details on who is logged in 
  3.  GO 
  5.  -- SQL Server 2008 
  6.  EXEC SP_WHO2         // even more details 
  7.  GO 
  9.  -- Run as database owner to see ALL connected processes as well. 

For every DBA this is a doddle and doesn't warrant its own article but for those of us who merely use SQL Server Management Studio (SSMS) and Microsoft's SQL Server 2008 R2 for development purposes, the once-in-a-blue-moon restore from backup process is quickly forgotten.

You need to set the database to single-user mode.

  1. In SSMS, connect to an instance of the SQL Server Database Engine, and then expand that instance.
  2. Right-click the database to change, and then click Properties.
  3. In the Database Properties dialog box, click the Options page.
  4. From the Restrict Access option, select Single.
  5. If other users are connected to the database, an Open Connections message will appear. To change the property and close all other connections, click Yes.
  1. in SSMS, Right-click on the database
  2. Select Tasks > Restore... > Database
  3. Specify the "to a point in time" if you don't want to restore from the most recent backup and double-check the "Start/Finish Date" is the one you want.
  4. OK

  • ssms restore database in use
  • Cannot drop database because it is currently in use
  • Restoring a SQL Database Backup Using SQL Server Management Studio
  • Unable to restore database "..because it is in use by this session."
  • determine who is connected to sql database


Category: Databases :: Article: 491

Credit where Credit is Due:

Feel free to copy, redistribute and share this information. All that we ask is that you attribute credit and possibly even a link back to this website as it really helps in our search engine rankings.

Disclaimer: Please note that the information provided on this website is intended for informational purposes only and does not represent a warranty. The opinions expressed are those of the author only. We recommend testing any solutions in a development environment before implementing them in production. The articles are based on our good faith efforts and were current at the time of writing, reflecting our practical experience in a commercial setting.

Thank you for visiting and, as always, we hope this website was of some use to you!

Kind Regards,

Joel Lipman

Related Articles

Joes Revolver Map


Badge - Certified Zoho Creator Associate
Badge - Certified Zoho Creator Associate

Donate & Support

If you like my content, and would like to support this sharing site, feel free to donate using a method below:

Donate to Joel Lipman via PayPal

Donate to Joel Lipman with Bitcoin bc1qf6elrdxc968h0k673l2djc9wrpazhqtxw8qqp4

Donate to Joel Lipman with Ethereum 0xb038962F3809b425D661EF5D22294Cf45E02FebF
© 2024 Joel Lipman .com. All Rights Reserved.