Quick Answer
Undo an UPDATE without WHERE in SQL Server in 4 ways. Use ROLLBACK when the transaction is still open. Restore a backup copy to a point in time for a committed UPDATE. Query fn_dblog for the old values when the log still has them. Preview Update transactions in a log reader for an offline LDF. Stop log backups before you start. Test every query on a copy first.
One forgotten WHERE clause updates every row of a table in seconds. SQL Server shows no undo button after a committed UPDATE. Old values exist in only two places, your backups and your transaction log.
This guide shows which of 4 methods fits your case. We executed the T-SQL for Method #2 and Method #3 on SQL Server 2022 with a 3 row test table. Real output sits under both methods.
What Makes an UPDATE Undoable in SQL Server?
Three facts decide the result, the commit state, the recovery model and the age of your last log backup. Match your case in this table first.
| Your situation | What it means | What to do |
|---|---|---|
| The transaction is still open | SQL Server has not committed the new values | Execute ROLLBACK TRANSACTION (Method #1) |
| Committed, FULL recovery, full backup and log backups exist | You can rebuild the data as it was before the UPDATE | Restore a copy with STOPAT (Method #2) |
| Committed, FULL recovery, no log backup since the UPDATE | Microsoft states the log is truncated only after a log backup. The old values still sit in the online log | Query fn_dblog or open the LDF in a log reader (Method #3 and #4) |
| Committed, SIMPLE recovery | Microsoft states a checkpoint truncates the log automatically | Act within minutes with Method #3 or restore a full backup |
| Committed, no backup and a truncated log | SQL Server no longer stores the old values | Look for exports, reports, replicas and application caches |
Our recovery models and backup types guide explains how all three models treat the log.
Which Versions and Permissions Apply?
These tables list what the methods need. Log reader figures come from the product page.
System Specifications
| Component | Requirement |
|---|---|
| Server permission | sysadmin role for fn_dblog, BACKUP LOG and RESTORE. We executed every test as sysadmin |
| Disk space on the server | Free space for a full copy of the database and its log backups when you restore a copy |
| PC for the log reader | Windows up to Windows 10, 512 MB of RAM and 50 MB of free disk space |
| Recovery model | FULL or bulk logged for STOPAT. Microsoft documents point in time options for these two models only |
Software Specifications
| Item | Requirement |
|---|---|
| SQL Server version | Tested on SQL Server 2022 (RTM CU26) Express on Linux. Microsoft documents STOPAT through SQL Server 2025. The log reader lists SQL Server 2017 and earlier |
| Backup files | A full backup that ends before the UPDATE and every log backup after it |
| fn_dblog function | Undocumented and unsupported by Microsoft. Use a restored copy for your first test |
| Client tool | SQL Server Management Studio or sqlcmd |
How do You Undo an UPDATE Without a WHERE Clause?
Start with Method #1 and move down the list. Copy your database files before you start Method #2.
Method #1: Roll Back the Open Transaction (Free, Before COMMIT)
ROLLBACK undoes the UPDATE only while the transaction is open. Check the open transaction count in the same session.
SELECT @@TRANCOUNT AS open_transactions;
ROLLBACK TRANSACTION;
SSMS commits a plain UPDATE at once in autocommit mode. In that case @@TRANCOUNT shows 0 and ROLLBACK has nothing to undo.
Heads Up. We did not execute Method #1 in our test. Our how to rollback a transaction guide shows the limits of ROLLBACK.
Method #2: Restore a Copy to a Point in Time (Free, Needs Log Backups)
Restore the database under a new name and stop before the UPDATE. Then copy the old values back into the live table. This method never touches your live database until the last step.
BACKUP LOG YourDatabase TO DISK = N'D:\Backups\YourDatabase_tail.trn';
RESTORE DATABASE YourDatabase_copy
FROM DISK = N'D:\Backups\YourDatabase_full.bak'
WITH MOVE N'YourDatabase' TO N'D:\Data\YourDatabase_copy.mdf',
MOVE N'YourDatabase_log' TO N'D:\Data\YourDatabase_copy.ldf',
NORECOVERY;
RESTORE LOG YourDatabase_copy
FROM DISK = N'D:\Backups\YourDatabase_tail.trn'
WITH STOPAT = N'2026-11-30T10:14:00', RECOVERY;
UPDATE o
SET o.salary = c.salary
FROM dbo.Emp AS o
JOIN YourDatabase_copy.dbo.Emp AS c ON c.id = o.id;
- Select the time. Use a time a few seconds before the UPDATE started.
- Restore every log backup. Microsoft requires the same STOPAT value on every RESTORE LOG statement and NORECOVERY on all steps before the last one.
- Check the time limit. STOPAT times after your last log backup put the copy in the restoring state.
Our test captured the time before the UPDATE and then set every salary to 999. After the restore the copy returned the original values and the final UPDATE repaired the live table.
| id | name | Live table after UPDATE | Restored copy at STOPAT |
|---|---|---|---|
| 1 | Ann | 999 | 100 |
| 2 | Bob | 999 | 200 |
| 3 | Cid | 999 | 300 |
Method #3: Query the Old Values From fn_dblog (Free, Active Log Only)
SQL Server writes one LOP_MODIFY_ROW record per row for an UPDATE of a fixed length column. Column RowLog Contents 0 stores the bytes from before the UPDATE and RowLog Contents 1 stores the bytes after it.
| Slot ID | RowLog Contents 0 (starts at salary) | RowLog Contents 1 (starts at salary) | Value before |
|---|---|---|---|
| 0 | 64000000 03000001… | E7030000 03000001… | 100 |
| 1 | C8000000 03000001… | E7030000 03000001… | 200 |
| 2 | 2C010000 03000001… | E7030000 03000001… | 300 |
SQL Server stores an int in reverse byte order. That makes 64000000 equal 100 and E7030000 equal 999. This query joins every log record to its live row and returns the old value.
DECLARE @xid nvarchar(14) = (
SELECT TOP (1) [Transaction ID]
FROM sys.fn_dblog(NULL, NULL)
WHERE [Operation] = N'LOP_MODIFY_ROW' AND [AllocUnitName] LIKE N'dbo.Emp%'
ORDER BY [Current LSN] DESC);
SELECT e.id,
e.salary AS current_salary,
CAST(CAST(REVERSE(SUBSTRING(l.[RowLog Contents 0], 1, 4)) AS binary(4)) AS int) AS old_salary
FROM dbo.Emp AS e
CROSS APPLY sys.fn_PhysLocCracker(%%physloc%%) AS p
JOIN sys.fn_dblog(NULL, NULL) AS l
ON l.[Operation] = N'LOP_MODIFY_ROW'
AND l.[AllocUnitName] LIKE N'dbo.Emp%'
AND l.[Transaction ID] = @xid
AND l.[Slot ID] = p.slot_id
AND CONVERT(int, CONVERT(varbinary(4), '0x' + RIGHT(l.[Page ID], 8), 1)) = p.page_id
ORDER BY e.id;
Our test returned id 1, 2 and 3 with the current salary 999 and the old salary 100, 200 and 300. Join the result to an UPDATE statement only after you compare every row by hand.
Heads Up. We tested one fixed length column that changed in place. Other column types use other byte offsets and a page split moves the row away from its slot. Microsoft gives no support for fn_dblog or %%physloc%%.
Method #4: Preview Update Transactions in SQL Server Log Explorer (Paid, Offline LDF)
SQL Server Log Explorer analyzes Insert, Update and Delete transactions from a live server or from an offline LDF file. Its preview lists the transaction name, time, query and table name. You see which rows the UPDATE touched without a join.
- Select the online server or the offline LDF file of your database.
- Scan the log and open the Update transactions in the preview.
- Filter the list by date range and by the Update operation type.
- Export the result as a SQL Server database, a SQL script or a CSV file.
Heads Up. Product page text lists the export of Update transactions and does not state that the software reverses an UPDATE. Compare exported values with your live rows before you build a fix. Coverage stops at SQL Server 2017 and the software needs a healthy MDF file.
SQL Server Log Explorer
Preview Update transactions from an online server or an offline LDF.
Which Mistakes Make the Undo Fail?
- Log backups after the UPDATE. Old records move into the backup file and exit the online log. Restore from that file with Method #2.
- Another UPDATE touched the same rows. Restoring old values overwrites newer work. Compare the key and a last modified column first.
- Key or row size edits. Method #3 matches rows by page and slot. Moved rows return no match.
- You restored over the live database. Restore to a copy and move only the wrong values back.
Our find who deleted records guide shows how to join the begin record of a transaction to the login and the start time.
FAQs
Can You Undo a Committed UPDATE in SQL Server Without a Backup?
Yes, while the old values remain in the online log. Query fn_dblog or open the LDF in a log reader before the next log backup. SIMPLE recovery clears them at the next checkpoint.
Does ROLLBACK Undo an UPDATE That Already Finished?
No. ROLLBACK works only before the COMMIT. Autocommit mode commits every statement when it ends.
Which Recovery Model does STOPAT Need?
FULL or bulk logged. Microsoft documents point in time options for these two models only.
How do You Find the Time of the UPDATE?
Look up the Begin Time column of the LOP_BEGIN_XACT record that shares the Transaction ID with the LOP_MODIFY_ROW records. Use a time a few seconds before it as your STOPAT value.
How do You Prevent an UPDATE Without WHERE?
Start with BEGIN TRANSACTION and check @@ROWCOUNT before COMMIT. Grant UPDATE rights through a role and test every statement on a staging copy.
About this guide. Andrew Jackson is a SQL Server DBA and blogger. He writes about transaction logs, database recovery and SQL Server errors. We checked this guide against Microsoft documentation on 30 Nov 2026 for SQL Server 2019, 2022 and 2025. We executed the T-SQL of Method #2 and Method #3 on SQL Server 2022 Express on Linux. Method #1 is not executed in our test.
Microsoft documents log truncation on its transaction log page and point in time restores on its RESTORE arguments page.
