Tuesday, 29 August 2017

What is the Difference between DELETE and TRUNCATE in MS-SQL Server

Blow mention the difference of  between DELETE and TRUNCATE  in MS-SQL Server.


1)   Command Type

       DELETE  -  DML(Data Manipulation Language )Command.
       TRUNCATE  - DDL (Data Definition Language)Command.
   
2) Role Back

      DELETE  - Can Role Back using Transactions.
      TRUNCATE  - Can not Role Back.

3) Identity  Reset

      DELETE  - Identity Column didn't Reset.
      TRUNCATE  - Identity Column Reset.

4) Lock

      DELETE  - Row lock ,each row is locked to Delete.
      TRUNCATE  - Table lock ,whole table is locked to remove all records.

5) Where Condition

       DELETE  - Support for Where Condition.
       TRUNCATE  - Didn't Support for Where Condition.

No comments:

Post a Comment

Single Responsibility Principle (SRP)