Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

DELETE

SQL Server 2000

Removes rows from a table.

Syntax
DELETE 
   [ FROM ] table_name  
   [ WHERE < search_condition > ]
Arguments
FROM
Is an optional keyword that can be used between the DELETE keyword and the target table_name.
table_name
Is the name of the table from which the rows are to be removed.
WHERE
Specifies the conditions used to limit the number of rows that are deleted.
<search_condition>
Specifies the restricting conditions for the rows to be deleted. There is no limit to the number of predicates that can be included in a search condition.
Remarks

If a WHERE clause is not supplied, DELETE removes all the rows from the table.

If a search condition is specified, it is applied to each row of the table; and all rows for which the result of the search condition is TRUE are marked for deletion.

The search condition is evaluated for each row of the table before any deletions occur.

All rows that are marked for deletion are deleted at the end of the DELETE statement prior to the checking of any integrity constraint.

The DELETE statement might fail if it violates a FOREIGN KEY constraint. If the DELETE removes multiple rows and any one of the removed rows violates a constraint, the statement is canceled, an error is returned, and no rows are removed.

Examples

A. Using DELETE with no parameters

The following example deletes all rows from the Customers table in the Northwind database.

DELETE Customers

B. Using DELETE on a set of rows

The following example uses the Customers table in the Northwind database. Because CompanyName may not be unique, the following example deletes all rows in which CompanyName is Eastern Connection.

DELETE FROM Customers WHERE CompanyName = 'Eastern Connection'

Show:
© 2015 Microsoft