Top Keyword With Delete Statement In SQL
In this article i will explain how to use the top keyword in a delete query to delete only the top few records.
Basically, most of us know about top, we can
use it in a select query to get the top element from the query. But TOP can also
be used with Insert, Delete and Update commands for the table as well. We will
see how we can use TOP with Delete statement.
Delete top (N) from <Table Name> where <Cond>
where N represents number of top rows to be deleted.
We have table named Employee.
To delete top 2 employees from Employee Table
having Salary greater than 20,000.