SQL Server 101 – How to Delete Top N records ?

Assume that you have a table named “Employee” in MS SQL Server and you would like to delete the top 1000 rows from the table. You can use the SQL Query with the TOP (N) as option as shown below. Here’s N is the number of records that you want to delete.

How to Delete Top N records in MS SQL Server ?

DELETE TOP (1000)
FROM Employee
WHERE IsMarkedForDelete = 1

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

In this blog post, let’s learn about the error message “1459 – An error occurred while accessing the database mirroring...
In this blog post, let’s learn about the error message “7937 – Columnstore index has one or more missing column...