SQL Server: Truncate Command

 SQL Server     sbo     Updated on Sep 22, 2013     VIKRAM     462   

Introduction:

In this article i will explain what is Truncate Command and how to use Truncate Command in SQL Server.

Description:

 In previous articles i explained How to create a table in SQL ServerHow to alter table column in SQL ServerHow to add a column to table and How to delete a column from table in SQL ServerHow to rename a column and How to rename a table in SQL Server, Update Command, and Delete Command. Now i will explain what is Truncate Command and how to use Truncate Command in SQL Server.

Here i'm using Employee table.

By Truncate command all the records will be deleted at a time and we can't get data, by using Delete command we can restore the data because the description of each record is maintained in the log file.

Syntax:

Truncate table <table-name>

Example:

Truncate table Employee

Execute the above statement. All records will be deleted at a time.

Note: If there is any identity column then Identity Seed will be reset to start value.

  Related Articles
SQL Server: Drop Command
SQL Server: Delete Command
SQL Server: Update command
SQL SERVER – DDL, DML, DCL and TCL Commands
  Recent Articles
SQL Server: Drop Command
SQL Server: Delete Command
SQL Server: Update command
SQL SERVER – DDL, DML, DCL and TCL Commands