SQL Server Error 1236: Transaction Session ID Rolled Back
In this article
SQL Server error 1236 (“Transaction session ID was rolled back”) is a generic error that appears when a transaction or session is rolled back by the server, often because of a deadlock, a timeout, or an internal resource issue. The fix starts with reading the full error message and the SQL Server error log to find the underlying cause, then addressing that cause—usually by resolving blocking, increasing a timeout, or fixing application transaction handling. You do not need to reinstall SQL Server or restore a backup unless the error is accompanied by corruption messages.
What You'll Need
- Access to SQL Server Management Studio (SSMS) or Azure Data Studio with at least VIEW SERVER STATE permission (or sysadmin).
- Permission to read the SQL Server error log and, if needed, the Windows Event Viewer.
- The exact error text, including any accompanying error number and message, plus the time it occurred.
- Optional: the application or query that triggered the error, and its connection string or timeout settings.
Step-by-Step
- Capture the full error. Error 1236 is often a secondary message. In SSMS, look at the Messages tab and note every error number and text, not just the last line. If the error came from an application, check its logs for the same timestamp. The surrounding messages usually name the real cause (for example, a deadlock victim message or a timeout).
- Check the SQL Server error log. In SSMS, expand Management > SQL Server Logs, or run
EXEC sp_readerrorlog;in a query window. Look for entries around the time of the error. Search for terms like “deadlock,” “timeout,” “rollback,” or “session.” If you see a deadlock graph, open it to identify the two sessions and the objects they were fighting over. The exact menu labels can differ slightly between SSMS versions, but the log location is consistent. - Look for blocking and deadlocks. Run
EXEC sp_who2;to see active sessions and any with a BlkBy value. For a deadlock, use the system health session: right-click Management > Extended Events > Sessions > system_health and choose View Target Data, or query the ring buffer withSELECT * FROM sys.dm_xe_session_targets;. If you find a deadlock, identify the queries involved and add appropriate indexes or reorder access to reduce contention. - Check for long-running transactions. Query
sys.dm_tran_active_transactionsandsys.dm_exec_sessionsto find sessions that have been open a long time. A transaction that stays open while waiting for user input or a slow application call can be rolled back by the server or by a client timeout. If you find one, work with the application owner to shorten the transaction or move the wait outside the transaction. - Review timeout settings. If the error appears after a fixed interval, the client or server may be timing out. In SSMS, check Tools > Options > Query Execution > SQL Server > General for the execution timeout. For applications, check the connection string or data access layer for a command timeout. Increasing a timeout can mask a slow query, so also tune the query or add indexes.
- Check for resource pressure. Run
SELECT * FROM sys.dm_os_sys_info;and review CPU, memory, and disk latency in Performance Monitor or the built-in reports. If the server is under memory pressure, queries may be rolled back. Look for excessive page life expectancy drops or high disk queue length. Address the pressure by adding memory, optimizing queries, or moving workloads. - Examine application transaction handling. If the error occurs in a specific application, review its code for transactions that are not committed or rolled back promptly, or for missing error handling. A transaction that remains open after an error can cause subsequent errors. Ensure the application uses try/catch/finally blocks to close transactions.
- Test with a minimal reproduction. If you can reproduce the error, run the same query or operation in a controlled environment. Use SQL Server Profiler or Extended Events to capture the exact statement and session. This helps isolate whether the issue is in the query, the application, or the server configuration.
- Apply fixes and monitor. After making changes (indexes, query rewrites, timeout adjustments, or application fixes), monitor the error log and application logs for recurrence. Set up an alert or a scheduled job to check for error 1236 so you can respond quickly if it returns.
Common Mistakes
- Treating error 1236 as the root cause. It is usually a symptom. Fixing the symptom without finding the underlying deadlock or timeout will not stop it from happening again.
- Ignoring the application layer. Many rollbacks originate from client timeouts or improper transaction handling, not from SQL Server itself.
- Increasing timeouts as a first step. This can hide performance problems and lead to longer lock holds and more blocking.
- Restarting SQL Server unnecessarily. A restart clears the error log and can destroy evidence. Capture logs before restarting.
- Assuming corruption. Error 1236 alone does not indicate database corruption. Check for accompanying messages like 823 or 824 before running DBCC CHECKDB.
Tips
- Enable deadlock monitoring by ensuring the system_health session is running (it is on by default).
- Use Extended Events to capture rollback events with a session_id filter to narrow down the source.
- Keep statistics and indexes maintained; stale statistics can cause poor plans that lead to timeouts.
- Document the exact error text and time; it helps when searching for known issues or contacting support.
- For applications, use short transactions and avoid user interaction inside a transaction.
Troubleshooting
If the error persists after the steps above, work through these checks in order:
- Check for known issues. Search the Microsoft support site for the exact error text and your SQL Server version. Some cumulative updates address specific rollback scenarios.
- Review Windows Event Viewer. Look in the Application and System logs for errors from SQL Server or the disk subsystem around the same time.
- Run DBCC CHECKDB only if you see corruption messages. If you see errors 823, 824, or 825, run
DBCC CHECKDBon the affected database. Be aware that this can take time and may require downtime; consider restoring from a backup if corruption is confirmed. - Isolate the session. If you can identify the session_id from the error, query
sys.dm_exec_sessionsandsys.dm_exec_requestsfor that session to see what it was doing. If the session is gone, use the default trace or Extended Events to find historical data. - Engage support. If you cannot find the cause, collect the error log, the output of
sp_who2, and any deadlock graphs, and contact Microsoft support or a qualified DBA.
Frequently Asked Questions
What does “Transaction session ID was rolled back” mean?
It means SQL Server rolled back a transaction or session, often because of a deadlock, a timeout, or an internal error. The message itself is a notification, not the root cause.
Is error 1236 dangerous?
Not by itself. It indicates a rollback occurred, which protects data integrity. The danger depends on the underlying cause; a deadlock is normal under contention, while corruption messages are serious.
Can I prevent error 1236?
You can reduce its likelihood by tuning queries, managing transactions properly, and monitoring for blocking and deadlocks. You cannot eliminate all rollbacks, as some are part of normal operation.
Does error 1236 mean data is lost?
No. A rollback undoes uncommitted changes, so committed data remains intact. However, the application may need to retry the failed operation.
Should I restart SQL Server to fix it?
No. Restarting clears diagnostic information and does not address the cause. Investigate first, then restart only if advised by support.
Where can I find more details about the rollback?
Check the SQL Server error log, the system_health session, and any application logs. The surrounding messages usually provide the specific reason.