SQL Tutorial - DELETE STATEMENT


The 'DELETE' statement is used to delete a single/multiple records according to the where condition given in a query. It is a DML statement.

The DELETE statement


The 'DELETE ' statement helps you delete one or more records from a table based on the where condition.

SQL DELETE Syntax


Delete from tablename where condition

The DELETE statement Example


The 'Employees' tables contains the following columns and their respective data type as shown below.

Table Name :

Employees

Column Name Data Type  
EmployeeID smallint Not Null
EmployeeName varchar(50) Not Null
DateOfBirth smalldatetime Not Null
DesignationID smallint Allows Null
DeptID smallint Allows Null
PhoneNo nvarchar(12) Allows Null
City nvarchar(50) Allows Null

The 'Employees' tables contains the respective data as shown below.

EmployeeID EmployeeName DateOfBirth DesignationID DeptID City
1 Richard Hughes 4/23/1945 12:00:00 AM 1 1 New Orleans
2 Taryn Sinclair 3/22/1980 12:00:00 AM 2 2 San Francisco
3 Ted Horowitz 3/31/1960 12:00:00 AM 3 4 New York
4 Jonathan Douglas 7/7/1971 12:00:00 AM 3 4 Salt Lake City
5 Miranda Leigh 7/19/1983 12:00:00 AM 7 3 New York
6 Jana Rae 9/23/1976 12:00:00 AM 8 2 Houston
7 Lita Rosanna 9/14/1982 12:00:00 AM 4 6 Long Island
8 Colin Flooks 12/29/1988 12:00:00 AM 4 2 Salt Lake City
9 Anthony Frank 2/22/1988 12:00:00 AM 9 3 San Francisco
10 Stephanie Lynn 7/30/1979 12:00:00 AM 8 2 Salt Lake City
11 Jack Martin 8/25/1985 12:00:00 AM NULL NULL Austin

Delete from Employees where EmployeeName ='Anthony Frank'

Also note that when entering values for datatypes of char,varchar, nvarchar and date, enclose the values within ' ' such as 'Anthony Frank'. values of datatype int, smallint goes in as is without any quotes.