Alter Database Failed Because a Lock Could Not Be Placed on Database Try Again Later.
SQL SERVER – 5061: FIX Error: Change DATABASE failed because a lock could non exist placed on database 'Database Proper noun'. Try over again later.
Every consulting date is dissimilar and I become to learn new things. In this blog post, I will share what I learned during my recent Comprehensive Database Functioning Wellness Check. During health check to demonstrate one of the scenarios we had created a test database in our surround. However, after the test was complete we wanted to take the database offline so we somewhen can drop it or bring it online if needed, notwithstanding, equally presently every bit we ran the command to take database offline, it gave is an fault related to alter database failed considering a lock could not be placed on database.
If you lot desire to larn how to take the database offline and online, you can read my earlier blog mail service here: SQL SERVER – T-SQL Script to Take Database Offline – Accept Database Online.
If you try to take your database offline and yous come across the following error:
Msg 5061, Level xvi, State 1, Line one ALTER DATABASE failed because a lock could not be placed on database 'database name'. Attempt once again subsequently. Msg 5069, Level 16, State 1, Line 1 ALTER DATABASE statement failed.
SOLUTION/WORKAROUND
In that example, you run first the following command endeavor to find your database in the listing. Information technology is totally possible due to some reason, your database connexion is still active and not terminated.
EXEC sp_who2
If you are comfortable you can hands kill the SPID past running following command.
After y'all get the error, run
KILL (SPID)
Once you impale all the active sessions y'all tin once more run the command specified in the blog post and take your database offline using alter database control.
Reference: Pinal Dave (https://blog.sqlauthority.com)
Related Posts
Source: https://blog.sqlauthority.com/2018/11/27/sql-server-5061-fix-error-alter-database-failed-because-a-lock-could-not-be-placed-on-database-database-name-try-again-later/
0 Response to "Alter Database Failed Because a Lock Could Not Be Placed on Database Try Again Later."
Post a Comment