SQL Server - Delete Data using DELETE Statement

Use the DELETE statement to delete data from the existing table in the current schema or tables of the schema on which you have the DELETE privilege.

Syntax:

DELETE FROM table_name [WHERE Condition];

Here we will delete the data in the Employee table shown below.

You can delete the specific record(s) from the table using the WHERE clause. The following will delete a record from the Employee table where EmployeeID is 1.

T-SQL: Delete a Record
DELETE FROM Employee WHERE EmployeeID = 1;

Now, the Select * from Employee query will display the following rows.

In the same way, the following will delete all employees from the Employee table whose Salary is more than 40000.

T-SQL: Delete Records
DELETE FROM Employee WHERE Salary > 40000;

Now, the Select * from Employee query will display the following rows.

The following DELETE statement will delete all the records from the Employee table.

T-SQL: Delete All Rows
DELETE FROM Employee;

Now, the Select * from Employee query will display the empty table.

Note:
You cannot delete the value of a single column using the DELETE statement. Use the UPDATE statement to set it NULL.
Want to check how much you know SQL Server?