T-SQL Tutorial

T-SQL Truncate table


This article shows how to delete all rows from a table in SQL Server database.
The T-SQL statement TRUNCATE TABLE removes all rows from a table, and do not change the structure of the table.
When you want to delete all the records in a table, use TRUNCATE TABLE and not DELETE, because truncated is faster and uses fewer system and transaction log resources.
TRUNCATE TABLE always locks the table, doesn't fire triggers.
TRUNCATE TABLE cannot be ran inside of a transaction.



Truncate table syntax

TRUNCATE TABLE table_name;

Truncate table example

TRUNCATE TABLE test_table;