Use of TRUNCATE TABLE (Transact-SQL)

Its silly but I did not know details about TRUNCATE TABLE.

  • Its similar to the DELETE statement with no WHERE clause;
  • Faster
  • DELETE removes rows one at a time and records an entry in the transaction log for each deleted row. TRUNCATE TABLE removes the data by deallocating the data pages used to store the table data and records only the page deallocations in the transaction log.
USE AdventureWorks;
SELECT COUNT(*) AS BeforeTruncateCount 
FROM HumanResources.JobCandidate;
TRUNCATE TABLE HumanResources.JobCandidate;
SELECT COUNT(*) AS AfterTruncateCount 
FROM HumanResources.JobCandidate;


By simplemsexchange Posted in SQL 2008

Leave a Reply

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

You are commenting using your 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 )


Connecting to %s