http://www.sqlservercentral.com/blogs/jeffrey_yao/2008/04/22/difference-between-truncate-and-delete/

Printed 2014/10/24 12:22PM

Difference between truncate and delete

By Jeffrey Yao, 2008/04/22

This is an old topic and well documented, just google it and I believe you will get a lot,

However, there is one difference that seems not being mentioned and actually I find it out myself only two hours ago. So here is the point

If a table is published for replication, it cannot be truncated, while it can still be deleted.

Otherwise, you will get the following msg

Msg 4711, Level 16, State 1, Line 1

Cannot truncate table 'xxx' because it is published for replication.

My environment is SQL Server 2K5 SP2 (developer edition)

Next time, when you are asked this question in an interview, just give this answer to impress your interviewer. [:)]

 

 


Copyright © 2002-2014 Simple Talk Publishing. All Rights Reserved. Privacy Policy. Terms of Use. Report Abuse.