How to truncate data from table in sql server

We'll learn here How to truncate data from database table.
So I have already created a employee table in test database  and inserted 5 records in Employee table
Let's select data from table with the help of below query.



























So we have the 5 records in table. To truncate the data from the table we have the TRUNCATE command  let's truncate this data from the table with the help of below query.

Syntax: TRUNCATE TABLE <TABLENAME>

Execute below command to truncate the data
TRUNCATE TABLE  Employee

output:
















Let's  check whether data is truncated or not from the table with the help of Select statement.


















So using the TRUNCATE command we can delete the entire data from the table. it does not allow   WHERE Clause.

No comments:

Post a Comment