How to unlock a table locked in SQL Server database?

In SQL Server, tables can be unlocked using the following methods:

  1. In SQL Server Management Studio, you can manually unlock a table by executing the following command.
ALTER TABLE table_name SET (LOCK_ESCALATION = DISABLE)
  1. Restarting the SQL Server service can also unlock the table, but this will result in all running transactions and connections being disrupted.
  2. By using the KILL command, you can terminate the session that is currently using the table, thus unlocking the table. For example, execute the following command:
KILL <session_id>

Please make sure you understand the reason for table locking before performing the above operations and handle with caution to avoid data loss or any other issues.

广告
Closing in 10 seconds
bannerAds