Difference between Truncate and Delete commands in T-SQL

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′


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s