Exclusive access could not be obtained because the database is in use
Posted by Raj
System.Data.SqlClient.SqlError: Exclusive access could not be obtained because the database is in use.
Error:
Restore Failed For Server 'MyServer' (Microsoft.SqlServer.Smo)
Additional information:
System.Data.SqlClient.SqlError: Exclusive access could not be obtained
because the database is in use. (Microsoft.SqlServer.Smo)
Solution:
1.execute SP_WHO
EXEC sp_who
2.Execute KILL 53 /Kill 116
3.Restore from another database.
Right click on database which you want to restore
4.Done.
OR
Try below code to fix "System.Data.SqlClient.SqlError: Exclusive access could not be obtained because the database is in use" error
USE MASTER;
ALTER DATABASE MyDb1 SET SINGLE_USER WITH ROLLBACK IMMEDIATE ;
RESTORE DATABASE MyDb1 FROM DISK = N'[file path]';
ALTER DATABASE MyDb1 SET MULTI_USER with ROLLBACK IMMEDIATE;
Error:
Restore Failed For Server 'MyServer' (Microsoft.SqlServer.Smo)
Additional information:
System.Data.SqlClient.SqlError: Exclusive access could not be obtained
because the database is in use. (Microsoft.SqlServer.Smo)
Solution:
1.execute SP_WHO
EXEC sp_who
2.Execute KILL 53 /Kill 116
3.Restore from another database.
Right click on database which you want to restore
4.Done.
OR
Try below code to fix "System.Data.SqlClient.SqlError: Exclusive access could not be obtained because the database is in use" error
USE MASTER;
ALTER DATABASE MyDb1 SET SINGLE_USER WITH ROLLBACK IMMEDIATE ;
RESTORE DATABASE MyDb1 FROM DISK = N'[file path]';
ALTER DATABASE MyDb1 SET MULTI_USER with ROLLBACK IMMEDIATE;
This entry was posted on October 4, 2009 at 12:14 pm, and is filed under
Microsoft.SqlServer.Smo,
Restore Failed For Server,
System.Data.SqlClient.SqlError
.You can leave a response, or trackback from your own site.