Difference between DELETE and TRUNCATE Command

Delete command removes the rows from a table based on the condition thate we provide with a WHERE clause.Truncate will actually remove all the rows from a table and there will be no data in the table after we can run the truncate command.

Truncate:

1) Truncate is faster and uses fewer system and transaction log resources than Delete.

2) Truncate removes the data by deallocationg the data pages used to store the tables'sdata,and only the page deallocations are recorded in the transaction log.

3) Truncate removes all rows froma table ,but the table structure and its columns ,constraints ,indexes and so on remain.The counter used by an idetity for new rows is reset to the seed for the column.

4) You cannot use Truncate table on a tbale referenced by a Foreign key constant.Because Truncate table is not logged,it cannot activate a trigger.

5) Truncate cannot be rolled back.

6) Truncate is dll command.

7) Truncate resets identity of the table.

Delete:

1) Delete removes rows one at a time and records an entry in the transaction log for each deleted row.

2) If you want to retain the identity counter,use delete instead.If u want to remove table definition and its data,use the DROP TABLE statement.