Deleting data from SQL Server database tables
You use the DELETE
statement to delete unwanted data from SQL Server database tables.
To execute the DELETE
statement, the user must at least have the DELETE
permission assigned on the target table.
The basic syntax for a DELETE
statement is as follows:
[WITH <common_table_expression> [,...n]] DELETE [TOP (expression) [percent]] [FROM] table_name | view_name | rowset_function [WITH table_hint] <outputclause> [FROM table_source] WHERE search_conditions
The following are the arguments of a DELETE
statement:
WITH
: This keyword specifies the CTE that you can reference in yourDELETE
statementTOP
: Specify this keyword to only delete a specific number or percent of rows from the top of the querytable_name | view_name ...
Get SQL Server 2014 Development Essentials now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.