Sunday, January 10, 2010

DELETE vs TRUNCATE

TRUNCATE TABLE [TableName]
This method is fast, but should not be used on any table that is used
for replication, or if there are ON DELETE triggers present on the table.
This method will simply remove all the rows in the table in a single operation.

DELETE FROM [TableName] WHERE xxxxxx
This method works row by row, and fires triggers, and updates the transaction
logs. This method will be slower on large tables than TRUNCATE but should
be the only method you use if you have ON DELETE triggers, or the table is
included in replication.

http://www.softstuff-consulting.com/kbase/showkb.asp?id=15

No comments:

Post a Comment