Categories
Dynamics NAV Microsoft SQL Server

ALTER DATABASE failed because a lock could not be placed on database

ALTER DATABASE failed because a lock could not be placed on database ‘{DatabaseName}’. Try again later.

Cause:
One or more processes regarding {DatabaseName}, also in sleeping status, are blocking your query

Solution:
Execute
[sourcecode lang=”sql”]EXEC sp_who2 –or sp_who[/sourcecode]
to know the list of SPIDs’ processes where DBName is {DatabaseName}
then execute the following command for each of them to kill these processes
[sourcecode lang=”sql”]KILL {SPIDNumber} –e.g. KILL 55[/sourcecode]

Now finally you can execute your query to ALTER the database.

Did my solution solve your problem? Leave a reply.

One reply on “ALTER DATABASE failed because a lock could not be placed on database”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.