Interviews Questions and Answers



What is the difference between Drop, Delete and Truncate statements in SQL Server?

Posted by: James
On 25 Mar 2012 | Views: 1516 | Categories: Database (SQL Server)
Interview Answers(2)

 On 25 Mar 2012 10:56:27 AM
Drop, Delete and Truncate, All operations can be rolled back.

Delete is a logged operation, which means deleted rows are written to the transaction log.Truncate is not a logged operation, which means deleted rows are not written to the transaction log.

Truncate is a little faster than Delete. You can have a where clause in Delete statement where as Truncate statement cannot have a where clause. Truncate will delete all the rows in a Table, but the structure of the table remains. Drop would delete all the rows including the structure of the Table.
 On 26 Mar 2012 02:04:44 AM
truncate also reset your identity column's value. e.g. reset, when you insert new records, it will start with id=1.

Post your Answers


Other lins

.Net Techies
Other lins