Software⏱️ 2 min read📅 2026-05-31

How to Fix: ALTER DATABASE failed because a lock could not be placed on database

SQL Server Management Studio 2008 issue with database lock

Quick Answer: The problem is caused by the use of "rollback immediate" which prevents the database from being taken offline. Remove or replace this option to resolve the error.

The error 'ALTER DATABASE failed because a lock could not be placed on database' occurs when the SQL Server instance is in a state where it cannot place locks on databases. This can happen due to various reasons such as database corruption, insufficient permissions, or when multiple processes are holding onto the database simultaneously.

⚠️ Common Causes

  • Database corruption or damage
  • Insufficient permissions to access the database
  • Multiple processes holding onto the database simultaneously

🔧 Proven Troubleshooting Steps

Method 1: Database Restart

  1. Step 1: Take the database offline by running the following command in SQL Server Management Studio:
use master;goalter database qcvalues set single_user with rollback immediate;go

Method 2: Check for Corruption and Run DBCC CHECKDB

  1. Step 1: Run the DBCC CHECKDB command to identify any database corruption issues.
use master;goDBCC CHECKDB ('qcvalues') WITH REPORT_ONLY;go

✨ Wrapping Up

To avoid this issue in the future, ensure that database maintenance tasks are performed during off-peak hours and consider implementing a backup strategy.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions