SQL Server error 628 (Extended error 911) occurs when you try to issue a save transaction (COMMIT or ROLLBACK) but the database engine detects active operations—such as locks, pending operations, or long-running sessions—that prevent finalization. Unlike many errors, this one doesn’t show a specific block reason, making it tricky to diagnose. The root cause is almost always a blocked resource (file, table, index), a stuck transaction, or a deadlock. Here’s how to resolve it immediately and permanently.

What You'll Need

  • A SQL Server client (SSMS, PowerShell, or query tool) with admin privileges
  • System Admin or database owner credentials
  • Access to SQL Server Management Studio (SSMS) or a scripting environment
  • Optional: SQL Server Profiler or Extended Events for advanced debugging (if available)

Step-by-Step Resolution

  1. Check for Active Locks

    Open SSMS and run a query to identify locked objects:

    SELECT
                OBJECT_NAME(lock_owner_id) AS ObjectName,
                LOCK_MODE,
                SPID,
                STATUS,
                ResourceDescription,
                WaitType
            FROM sys.dm_tran_locks
            WHERE IS_USER_LOCK = 1

    If locks are present, wait for them to release (if short-lived) or kill the offending session with: KILL [SPID] where SPID is the process ID (run in a new query window).

  2. Verify Deadlocks

    Query for deadlocks with: SELECT * FROM sys.dm_deadlocks. If deadlocks exist, review the graph to find stuck processes and resolve them.

    Manual cleanup: Kill the deadlock participant with the highest wait_time: EXEC sp_who2 @waittype = 'C', @waittime = 999999

  3. Check for Stuck Transactions

    Run: SELECT transaction_id, transaction_start_time, status, index_id, transaction_name FROM sys.dm_tran_session_transactions WHERE session_id = @@SPID to spot lingering transactions. Terminate them with: SELECT * FROM sys.dm_tran_active_transactions to identify active transactions, then kill them via: EXEC sys.sp_transact_kill @session_id

  4. Review Transaction Logs

    If the log is full, the server may fail to commit. Check log stats with: SELECT log_reuse_wait_status, log_write_wait_status, log_read_wait_status FROM sys.dm_os_performance_counters WHERE object_name = 'SQLServer:Database(YourDB):Transaction Log'

    If log_reuse_wait_status = 'Wait', free up space by truncating the log or adding more space with: ALTER DATABASE YourDB MODIFY FILE (NAME = YourLogFile, SIZE = 10GB)

  5. Restart the SQL Server Agent

    If the error persists due to background processes, restart the SQL Server Agent service via:

    1. Press WinKey + R, type services.msc, and restart SQL Server Agent
    2. Or use PowerShell: Restart-Service -Name MSSQLSERVERAGENT1

  6. Test with a Minimal Query

    Try committing a simple transaction to rule out local application issues: BEGIN TRANSACTION INSERT INTO TestTable VALUES ('Test') COMMIT If this works, the issue is in your application logic.

Common Mistakes

  • Ignoring Locks Killing sessions without checking locks first can cause cascading failures. Always verify locks before killing SPIDs.
  • Overlooking Log Space A full log prevents commits, yet many admins forget to check log usage until it’s too late.
  • Wrong SPID Target When killing processes, use the exact SPID returned by DMVs—misidentifying one can break unrelated transactions.
  • No Rollback in Deadlocks Killing the wrong participant in a deadlock may leave half-committed work in a bad state until the next restart.

Tips

  • Enable Extended Events For deeper debugging, create an XEvent session to monitor lock contention: CREATE EVENT SESSION [LockContention] ON SERVER ADD EVENT sqlserver.lock_acquired, ADD EVENT sqlserver.lock_released, ADD EVENT sqlserver.lock_waited WITH (MAX_MEMORY=4096KB, MAX_DISPATCH_LATENCY=30SECONDS)
  • Set Checkpoint Frequency Adjust checkpoint behavior to reduce log bottlenecks: ALTER DATABASE YourDB SET CHECKPOINT ON
  • Use Profiler for Patterns Capture repeated error 628 logs to spot recurring deadlocks or lock contention.
  • Test with Isolated Transactions If the app is written in a language that dynamically creates transactions, wrap queries with explicit isolation levels.

Troubleshooting

  1. Still stuck after steps 1–4? Check for:

    • Replication lag (if using MSRS)
    • Database corruption (run DBCC CHECKDB)
    • Third-party integrations blocking writes (e.g., BI tools or ETL jobs)
    If DB corruption is confirmed, restore from backup or repair the database.

  2. If the issue repeats daily, investigate:

    • Scheduled backups that truncate logs mid-operation
    • Nightly maintenance scripts that hold locks longer than expected
    Adjust backup windows or optimize scripts.

  3. For clustered environments, verify:

    • All nodes are reporting the same error
    • No silent failovers interrupted transactions
    If one node is blocking writes, consider failover or rebalancing.

Frequently Asked Questions

Why does SQL Server 2017 still show error 628 even after I killed the SPID?

Error 628 often persists if the transaction was still active in the session context or if the lock was held by a child transaction. Ensure you check sys.dm_tran_active_transactions before killing SPIDs, and verify the transaction was fully rolled back.

Is there a way to prevent this error from happening in the future?

Yes: implement lock escalation thresholds, monitor long-running transactions with alerts, and avoid nested transactions that create deadlocks. Tools like SQL Server’s built-in sys.dm_tran_active_transactions can flag unsafe transactions early.

What if I’m using Azure SQL Database and see this error?

Azure handles locks differently. Focus on:

  • Checking the sys.dm_exec_requests DMV for pending operations
  • Using Azure’s native transaction monitoring (e.g., sys.dm_os_performance_counters)
  • Setting up alerts for high wait times under Azure Monitor
Avoid manual KILL commands—Azure enforces stricter session isolation.

How do I know if my application is causing this error?

Test by replacing your app’s save logic with a minimal transaction. If the error disappears, the issue is in your code (e.g., missing ROLLBACK or unclosed connections). Review for:

  • Open cursors without FETCH
  • Improperly scoped transactions
  • Exposed connection pools leaking SPIDs

Can I fix this without restarting SQL Server?

Mostly yes. For non-production environments, use:

  • EXEC sp_who2 to identify blocking processes
  • Deadlock graphs in Profiler
  • Log truncation for log-heavy operations
A full restart is only needed for extreme cases (e.g., deadlock storms or corrupted sessions).

Does this error affect replication?

Yes, if the blocked session is a replication agent or publish/subscribe component. Check sys.dm_os_waiting_tasks for replication-related waits, and adjust replication queue sizes or optimize publish intervals if needed.