In focus

How To Delete Data In SQL Server 2014

In this article, we will learn how to delete data in a table in SQL Server 2014. We will also check whether any data is available in our table or not.

Gagan Sharma Apr 06, 2016

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:

1
Syntax:  DELETE FROM table_name;

Example:  Delete from Salesperson

Look at the below image:

2

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:

1
Query: Delete from Salesperson where Salary=18000

Output: 

3
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

sql server statement view

COMMENT USING