You might receive "Database could not be exclusively locked to perform the operation" or many error like such when you are trying to perform operation on database which is already been used by process or some other users.
In order to obtain "Exclusive lock" to perform some critical database operation when someone is already using database you can perform following steps as described below to solve your problem.
Earlier I have blogged in context of restore error, but it is not limited to only restore and since this is very common error you get stuck when you are trying to do some critical database operation i have decided to explain step by step so that it can help me and many others like me who are in same situation. :)
Solution to obtain exclusive locked to perform database operations.
To do so: File > Disconnect Object Explorer
Step 2: Connect Connection
To do so: File > Connect Object Explorer
Step 3: Open "New Query" window and run following command
use master
Note: Above command will make your current database to master which is important before we run following sequence of command.
Step 4: Copy and paste following sequence of command in Query window. Replace the word "MyDatabaseName" with Database name you are trying to get exclusive access.
1 comment:
Would changing the state of the system databases cause a denial of service on a production system?
I have the problem listed and I'd like to get it corrected without causing a DoS or filing an internal change request, if possible.
Here is a link with lots of into to the issue I'm having http://dba.stackexchange.com/questions/76029/checkdb-fails-on-msdb-and-master-system-databases
Post a Comment