Tuesday, December 06, 2011

Difference between TRUNCATE, DELETE in SQL-Server?

Posted by Rahul Kharde at 3:11 AM

DELETE
TRUANCATE
DELETE is DML Command.
TRUNCATE is DDL Command.
DELETE Command is slow
TRUNCATE is Faster
The DELETE command is used to remove specified rows from a table.
TRUNCATE removes all rows from a table.
DELETE Can be used with or without a WHERE clause
No WHERE clause is used
DELETE operation you need to COMMIT or ROLLBACK
The operation cannot be rolled back
DELETE does not reset identity of the table.
TRUNCATE Resets identity of the table.
Trigger get fired
Trigger doesn't get fired

Syntax

DELETE
DELETE FROM table_name WHERE [condition]
e.g
DELETE FROM employee WHERE empid=100

TRUNCATE
TRUNCATE TABLE table_name
e.g
TRUNCATE TABLE employee


If you enjoyed this post and wish to be informed whenever a new post is published, then make sure you subscribe to my regular Email Updates. Subscribe Now!


Kindly Bookmark and Share it:

YOUR ADSENSE CODE GOES HERE

0 comments:

Have any question? Feel Free To Post Below:

 

Popular Posts

Recent Comments

© 2011. All Rights Reserved | Help to understand .Net | Template by Blogger Widgets

Home | About | Top