SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Truncate Table


Truncate Table

Author
Message
Site Owners
Site Owners
SSCoach
SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)

Group: Administrators
Points: 18533 Visits: 220
Comments posted to this topic are about the item Truncate Table
John Mitchell-245523
John Mitchell-245523
SSC Guru
SSC Guru (79K reputation)SSC Guru (79K reputation)SSC Guru (79K reputation)SSC Guru (79K reputation)SSC Guru (79K reputation)SSC Guru (79K reputation)SSC Guru (79K reputation)SSC Guru (79K reputation)

Group: General Forum Members
Points: 79785 Visits: 17904
Can we have more questions where the answer is in the title of the question!

John
Tony Davis
Tony Davis
SSCrazy
SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)

Group: Administrators
Points: 2339 Visits: 1176
It would certainly help my average!

Seriously though, apologies for the mistakes made in today's and yesteday's QoDs.


Tony.

Bob Fazio
Bob Fazio
SSCertifiable
SSCertifiable (6.5K reputation)SSCertifiable (6.5K reputation)SSCertifiable (6.5K reputation)SSCertifiable (6.5K reputation)SSCertifiable (6.5K reputation)SSCertifiable (6.5K reputation)SSCertifiable (6.5K reputation)SSCertifiable (6.5K reputation)

Group: General Forum Members
Points: 6490 Visits: 684
I thought it had to be some sort of trick question. (Halloween and all). Smile
RichB
RichB
SSCertifiable
SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)

Group: General Forum Members
Points: 5752 Visits: 1085
Surely drop table is quicker?



Nicholas Cain
Nicholas Cain
SSCoach
SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)

Group: General Forum Members
Points: 17146 Visits: 6200
I do not believe that the answer is correct.

The question was the fastest way to delete every row in a table.
Delete and truncate are not the same thing.

Should the question have read "to remove all rows from a table" then I would agree with the truncate statement.
This does not take into account things like identity values which would continue from the most recent number rather than completely reseed post truncate.



Shamless self promotion - read my blog http://sirsql.net
John Mitchell-245523
John Mitchell-245523
SSC Guru
SSC Guru (79K reputation)SSC Guru (79K reputation)SSC Guru (79K reputation)SSC Guru (79K reputation)SSC Guru (79K reputation)SSC Guru (79K reputation)SSC Guru (79K reputation)SSC Guru (79K reputation)

Group: General Forum Members
Points: 79785 Visits: 17904
Nicholas Cain (10/30/2007)
I do not believe that the answer is correct.

The question was the fastest way to delete every row in a table.
Delete and truncate are not the same thing.

Should the question have read "to remove all rows from a table" then I would agree with the truncate statement.
This does not take into account things like identity values which would continue from the most recent number rather than completely reseed post truncate.


The question doesn't take that into account, therefore nor should your answer. DELETE and TRUNCATE do indeed work differently, but both have the effect of deleting all rows. I can't see the difference between "delete every row in a table" and "remove all rows from a table".

John

Edit: actually, having looked at the choices again, neither of the DELETE options has correct syntax anyway.
Paul Randal
Paul Randal
SSCoach
SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)

Group: General Forum Members
Points: 18056 Visits: 1737
Hmm - dropping the table is the fastest way as it logs the least and doesn't take any locks, compared to truncate table. I think that was a bad question as the answer they wanted was truncate - drop shouldn't have been an option.

Paul Randal
CEO, SQLskills.com: Check out SQLskills online training!
Blog:www.SQLskills.com/blogs/paul Twitter: @PaulRandal
SQL MVP, Microsoft RD, Contributing Editor of TechNet Magazine
Author of DBCC CHECKDB/repair (and other Storage Engine) code of SQL Server 2005
kapil_kk
kapil_kk
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10565 Visits: 2778
gr8 question with the answer in the title itself :-P

_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum








































































































































































SQLServerCentral


Search