0% found this document useful (0 votes)
126 views

SQL Server Interview Questions and Answers: - Difference Between Truncate VS Delete?

The document summarizes the key differences between truncate and delete in SQL Server: Truncate deletes all records at once without the ability to specify filters, while delete can delete rows using a where clause. Truncate is faster than delete as it removes data by deleting pages rather than individual rows. Triggers are not executed for truncate but are for delete as data is removed row by row. Truncate resets the identity value to zero while delete retains the existing identity values.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
126 views

SQL Server Interview Questions and Answers: - Difference Between Truncate VS Delete?

The document summarizes the key differences between truncate and delete in SQL Server: Truncate deletes all records at once without the ability to specify filters, while delete can delete rows using a where clause. Truncate is faster than delete as it removes data by deleting pages rather than individual rows. Triggers are not executed for truncate but are for delete as data is removed row by row. Truncate resets the identity value to zero while delete retains the existing identity values.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

SQL Server interview questions and answers: - Difference between

truncate VS delete?

This is the most HIT SQL Server interview question. We have lost the count of how much it has been
asked in SQL interviews.
Delete Truncate
Filters In delete we can specify a Truncate deletes all records, we can not
where clause. specify filters.
Data removal Delete removes data one row Truncate removes data by removing pages.
procedure at a time. Pages are 8 KB units which stores row data.
Performance Slower, as delete happens Truncate is faster as compared to delete as
row wise. data is removed in pages.
Triggers Triggers are executed in In truncate triggers are disabled.
delete as the data is removed
row wise.
Identity In delete the identity value is In truncate the identity is reset back to zero.
retained.

The above question and the answer is taken from the SQL Server interview question book written by
Shivprasad Koirala.

Here’s an awesome article, it covers 50 important SQL Server interview question.

Here’s an awesome video on Difference between Sub Query and co-related queries ?( SQL Server
interview questions )

You might also like