Using TRUNCATE TABLE

The TRUNCATE TABLE statement is the most efficient way to remove all rows from a table. Logically, this statement is identical to the DELETE statement without the WHERE clause, but unlike the DELETE statement, when TRUNCATE TABLE has been issued, SQL Server does not log individual row deletion in the transaction log. Therefore, the TRUNCATE TABLE statement is significantly faster. This performance difference can be very important with large tables. However, if you want to enjoy its efficiency, you have to remove all rows from a table. Even if the table is partitioned, you still need to remove all rows from all the partitions. Well, unless you have SQL Server 2016.

In SQL Server 2016, the TRUNCATE TABLE statement has been ...

Get SQL Server 2017 Developer's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.