In this article, we will learn how to delete data in a table in SQL Server 2014. The DELETE statement is used to delete the table data or a record of a table or to delete a view in SQL Server 2014.
The DELETE command is used to remove rows from a table. We can use a WHERE clause to only remove a specified row. Otherwise all rows will be removed by the Delete command.
After performing a DELETE operation you need to execute COMMIT or ROLLBACK the transaction to make the change permanently or to do undo. Also this operation will make all DELETE triggers on the table be executed.
We have an existing table Salesperson
Query: Select * from Salesperson
Look at the below image:
Syntax: DELETE FROM table_name;
Example: Delete from Salesperson
Look at the below image:
How to use WHERE clause
The WHERE clause specifies which record or records need to be deleted.
Syntax: DELETE FROM table_name WHERE = ' ';
Example: Look at this table:
Query: Delete from Salesperson where Salary=18000
Output:
The row with Salary=18000 is deleted.
How to removes a
TRIGGER consist of DML statement a Delete, Insert, Update for a table from the database.
Syntax:
Delete TRIGGER ON Table_Name for DELETE / INSERT / UPDATE
How to removes a
View:
Syntax:
DELETE VIEW ViewName
Here's a free e-book on SQL Server 2014:
Introducing Microsoft SQL Server 2014