Friday, February 3, 2012

Difference between drop and truncate in sql server

Hi friends here i will explain the difference between Drop and Truncate

As we have seen in the last post about the difference between Truncate and Delete today we will seen the Difference between Drop and Truncate visually 

Let's see we have the table with the following data as given below




now suppose if we perform truncate operation on it all the Records will be remove from it. as you can see it from givenn slide


Above you can see all the data will be deleted from the table but all the columns will be as it is.

Now if you use Drop Query then whole the table will be deleted
let's see the example below




















so now as given above if u try  select query you have the above errors because table is not exists.

so we have conclusion is that

Drop - deletes the data as well as structure
Truncate - deletes only the data, and resets the auto increment column to 0

No comments:

Post a Comment