SqlServer restore database error

Use this code to destory all existing connections before restore:

USE master;
GO
ALTER DATABASE YourDB
SET SINGLE_USER
WITH ROLLBACK IMMEDIATE;
ALTER DATABASE YourDB
SET MULTI_USER;
GO

Restarting the SQL Service solves my problems.


The problem is that your database is currently being used by others and probably has open connections. What you would need to do is close all the existing connections to it, and then restore your backup.

Here is a link showing how to kill active connections: http://wiki.lessthandot.com/index.php/Kill_All_Active_Connections_To_A_Database


Select the backup file to restore and go to options to select "Close existing connections to destination database" and click ok

Screenshot

Tags:

Sql Server