Delete and Truncate statement in Sql Server

By
Hi friends Today i am going to explain,what is Delete and Truncate statement in Sql Server . Sql  is the main element of any Database.If you want to understand full concepts (step by step) of Ms Sql Server then here .If you want o learn somethings in your life then patience is more necessary.If you understand all concept of Ms Sql Server then ado.net will very easy for you.
Delete and Truncate statement can be used to remove the data from the  table.

Delete Sql command: 
Syntax:
delete from Table Name where Clause.
Ex: delete from employee where sid=101;
Truncate Sql command:
Syntax:
truncate table Table Name;
Ex:
truncate table employee;
There are some differences between delete and truncate statement which is given below:
  1. In case of delete each row is deleted one by one and deleted entry is made within log file but In case of truncate table structure is drop and recreated rows are not deleted physically.
  2. Truncate is faster than delete.
  3. Within delete statement we can specify 'Where' clause but in truncate statement we can not specify the 'Where' clauses.
  4. In case of Identity column the difference is,if we run delete statement then insert a new record then identity column value will be the next value of the last inserted values.But if we run truncate statement and insert a new record the next value seed value.
  5. In case of Foreign key constraint the difference is, if child table does not have any record then we can run delete statement against parents table but we can not run truncate statement against parent table.
  6. Delete is DML Statement and truncate is DDL Statement.
  7. If record is deleted that can be recover but if record is truncated then can not recover.
Drop Sql command:
Drop command removes a table from the database.when one time delete then we can not recover it.
Syntax:
drop table Table Name;
Ex:
drop table employee;
For More:-

  1. Default Constraints in SQL
  2. Check Constraints is SQL
  3. Copy Data from one table to another table
  4. Create Dataset and Data Adapter
  5. Exception Handling

I hope this is helpful for you.
To Get the Latest  Free Updates Subscribe

1 comment:

  1. I ωant to to thanκ you for this great rеad!
    ! I certainlу loveԁ еvery bіt of
    it. I've got you bookmarked to check out new stuff you post…

    Look into my site: H�moriden

    ReplyDelete

Powered by Blogger.