Only an open transaction can be undone with a command
If the DELETE is still inside a transaction that nobody committed, a ROLLBACK undoes it. Once SQL Server commits the change, no SQL command reverses it. In that case, you need a backup, a history table, or another copy of the data.
Check for an open transaction
Run this in the same session where the delete ran:
SELECT @@TRANCOUNT AS open_transactions;
If the value is 1 or higher, a transaction is open, and ROLLBACK TRANSACTION; undoes its changes. If the value is 0, the delete was committed. Don’t run COMMIT in that session until you’ve checked what the open transaction contains, because COMMIT makes the changes permanent.
Ctrl+Z and SSMS won’t bring back committed rows
SQL Server Management Studio’s undo works on edits that haven’t been saved to the database yet, such as changes in the query editor or the results grid. It can’t reverse rows that were already committed.
Restore a copy, then copy back the missing rows
For a committed delete, the usual route is a restore to a new database name, followed by copying back only the missing rows. Restoring over the original replaces its current data, and Microsoft’s documentation says the effects of a restore can’t be undone, so don’t restore over it. The full steps, including log backups and STOPAT, are in how to recover deleted data from sql server database.
Use history if the table keeps it
Temporal tables, available in SQL Server 2016 and later, keep previous row versions in a history table. To see the table as it looked before the delete, use FOR SYSTEM_TIME AS OF with a time before the change:
SELECT *
FROM dbo.Orders FOR SYSTEM_TIME AS OF '2026-11-20 13:55:00'
WHERE OrderID = 1042;
Insert the rows you need back into the current table. A history table only holds changes made after system versioning was turned on, so a table that never had it won’t show earlier deletes. If the table has change data capture or an audit trigger, those tables may also hold the deleted values.
Check the rows that are still there
Before you change anything, look at the newest rows that remain, because they show where the gap starts. How to retrieve last 5 records in SQL covers that query. Only rows still in the table will appear, so the query can’t show the missing ones.
Reduce the chance of a repeat
- Run a
SELECTwith the sameWHEREclause before theDELETE, and check how many rows it returns. - Wrap manual changes in an explicit transaction, check
@@ROWCOUNT, and only thenCOMMIT. - Keep backups that you’ve tested, and use temporal history for tables where deleted rows matter.