TRUNCATE TABLE instantly removes all rows from a table, de-allocating data pages and resetting identity values without logging each deleted row.
TRUNCATE TABLE de-allocates data pages, so the table appears empty in one operation. It also resets IDENTITY seeds and keeps the table structure, constraints, and permissions intact.
The basic form is TRUNCATE TABLE schema.table_name;. SQL Server 2022+ adds PARTITIONS for partial truncation.
TRUNCATE TABLE [database_name.]schema.table_name
[WITH (PARTITIONS (partition_number | partition_range))];
Use TRUNCATE when you need a fast, full purge, do not need row-by-row logging, and the table is not referenced by a FOREIGN KEY. Use DELETE when filters, triggers, or foreign-key cascade actions are required.
TRUNCATE TABLE automatically resets the identity seed to the original start value. No DBCC CHECKIDENT call is needed afterward.
Not directly. Remove or disable the foreign-key constraints, TRUNCATE each child then parent table, and finally recreate or enable the constraints. Alternatively, DELETE with CASCADE can be used, though slower.
1. Always run inside a transaction in non-production to verify results.
2. Grant ALTER permission carefully; only owners can truncate.
3. Schedule during maintenance windows to avoid blocking readers.
Mistake 1 – Expecting triggers to fire. TRUNCATE bypasses DML triggers. Use DELETE if trigger logic is mandatory.
Mistake 2 – Forgetting foreign-key references. SQL Server blocks truncation when the table is referenced, even if the referencing table is empty. Drop/disable the constraint first.
You need to empty the OrderItems table after exporting historical data.
-- Disable FK so we can truncate
ALTER TABLE OrderItems DROP CONSTRAINT FK_OrderItems_Orders;
GO
TRUNCATE TABLE OrderItems;
GO
-- Recreate FK
ALTER TABLE OrderItems
ADD CONSTRAINT FK_OrderItems_Orders FOREIGN KEY (order_id)
REFERENCES Orders(id);
GO
• Does TRUNCATE reclaim disk space immediately?
• How do I truncate a partitioned table?
• What permissions are required to run TRUNCATE TABLE?
Yes. SQL Server marks the data pages as free so space becomes available for reuse in the filegroup right away.
The caller needs ALTER permission on the table (inherited by db_owner or dbo) or membership in sysadmin.
Absolutely. Because it is fully logged at the page level, wrapping it in a transaction allows a normal ROLLBACK to undo the truncation.