July 15, 2009 at 6:16 am
when restoring the database exclusive lock exists restoring dont successfully ?
how to resolve this .
thanks
July 15, 2009 at 6:36 am
Please clearify it further. What problem are u facing while restoration of db ?
July 15, 2009 at 6:44 am
Exclusive access could not be obtained because the database is in use.
and the restore is not able to occur.
Any ideas on how I can prevent this from happening?
July 15, 2009 at 6:51 am
You need to ensure that all connections are clear with the database you're attempting to restore, even your own. Once all the connections are clear, you can restore.
If it's an emergency situation, you can kick out most of the logins by using setting the database to restricted user or single user like this:
ALTER DATABASE AdventureWorks
SET SINGLE_USER
WITH ROLLBACK IMMEDIATE;
GO
--or
ALTER DATABASE AdventureWorks
SET RESTRICTED_USER
WITH ROLLBACK IMMEDIATE;
GO
Understand though, that using the option ROLLBACK IMMEDIATE will cause any outstanding transactions to be stopped and rolled back, but it will clear out the connections so that you can restore the database.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
July 15, 2009 at 7:04 am
appreciated for ur reply .
Thanks
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply