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: The information on this website is provided without warranty and any content is merely the opinion of the author. Please try to test in development environments prior to adapting them to your production environments. The articles are written in good faith and, at the time of print, are working examples used 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 - Valid till 8 May 2022 bc1qjtp4l4ra452wzvuk9a45yfj82zkahsyy2z379y
© 2022 Joel Lipman .com. All Rights Reserved.