Difference between DELETE and TRUNCATE command in SQL Server
Below are few points that differentiate the DELETE and TRUNCATE command.
| Sl. No. |
DELETE |
TRUNCATE |
| 1 | This removes the rows one at a time and then records it in the transaction log for each of those deleted row. | This used fewer transaction log than delete and is faster |
| 2 | This can be used with or without a Where clause | This removes all rows from a table |
| 3 | Can be rolled back. | Cannot be rolled back |
| 4 | It is a DML Command. | It is a DDL Command. |
| 5 | When an Identity is used , it is not reset | Identity is reset |
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)
Tags:





Comments
Richard Carr replied on Thu, 2012/07/05 - 4:57pm
Hi Senthil,
there's an error in your table of differences. It's a common misconception about TRUNCATE that it cannot be rolled back. This is not the case, you can roll back a TRUNCATE in SQL Server if you execute the truncation within a transaction and rollback that transaction in the same session.
What you cannot do is guarantee the ability to rollback a TRUNCATE from the log files when the database is full recovery mode.