Uncategorized

[SQL Server] Truncate vs Delete

  1. Truncate resets Identity of Table while Delete doesn’t
  2. Truncate removes all record from the table including all spaces allocated for the records are removed while Delete remains those spaces
  3. Truncate locks the entire table while Delete locks table row
  4. Truncate is DDL (Data Definition Language) command while Delete is DML (Data Manipulation Language) command
  5. Truncate can’t use WHERE clause while Delete can
  6. Trigger is not fired while truncated while being fired for DELETE
  7. Syntax:
    1. TRUNCATE table_name
    2. DELETE FROM table_name WHERE expression

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s