Difference between truncate and delete?
- In SQL Server there are a couple a ways you can delete rows from a table.
- You can use the TRUNCATE and DELETE command.
- The TRUNCATE command is like a DELETE command without the WHERE clause.
- When you TRUNCATE a table less information is logged. This means the TRUNCATE statement executes very fast.
- The simplest form you can remove all the rows from a database or you can add a WHERE clause to remove.
- To truncate the table we can use: Syntax: truncate table <table-name>
Example: truncate table employee
- To delete the table we can use: Syntax: delete from <tab-name>
Example: delete from employee
- To delete particular records in a table we can use where clause :
Syntax: delete from <tab-name> where <col-name>=’value’
Example: delete from employee where eno=’5657′