You are currently viewing How To Truncate Table in SQL Server

How To Truncate Table in SQL Server

How To Truncate Table in SQL Server

  • The truncate statement is used to delete all records from the table.
  • Truncate statement is a DDL (Data Definition Language) command.
  • It locks the whole table before deletion.
  • Truncated table can not be rolled back.
  • Truncate command reset the identity column.
  • Truncate command runs faster as compare to delete command because it only locks entire table and delete, and it does not create log file for deleted records.

TRUNCATE Table

First, we create a table and insert some values, then we truncate that table.

Inserting rows in the table.

Rows will be shown as below.

Run the truncate statement as below.

TRUNCATE TABLE tblEmployee

We see all the rows deleted as below.

Recommended Readings