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

When dealing with a relational database management system (RDBMS) like SQL Server, compatibility level is an important concept to understand....
In this blog post, let’s learn about the error message “49975 – Unable to load controller client certificate due to...
In this blog post, let’s learn about the error message “49973 – Cannot remove tempdb remote file to local tempdb...