Blog Post

Difference between truncate and delete

,

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. [:)]

 

 

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating