Saturday, January 31, 2015

Truncate Vs Delete

The fast way to delete a lot of data, but not all is to have a partitioned table or a partitioned view. But if you did not set up for that in advance, it is not going to help you know.


Deleting in batch as Stefan suggested is a good, provided that there is an index to support the condition for the deletion.


Yet an alternative is to create a new table and copy over the data you want to keep. This is a more advanced alternative, as it requires you to keep track of indexes, triggers, foreign keys and whatnots that also need to be copied.





Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

No comments:

Post a Comment