Hello, Welcome to my blog

Delete Top 100 Rows from SQL Server Tables

0 Comments »

Want the top 100 / n to remove records from a SQL Server table, it is very simple to achieve with the below mentioned query:

DELETE FROM MyTable
WHERE PK_Column
IN(
SELECT TOP 100 PK_Column
FROM MyTable
ORDER BY creation
)

Why do you want to delete top 100 rows from SQL Server Database?

If the size of my SQL Server table is too huge, I often tend to delete top n records instead of deleting whole table. To simplify what I am saying, lets say I have 1 million records in a table, then instead of deleting whole table in one go, it would be faster to delete 1000 rows in a loop in one go.

Stumble Upon Toolbar
8:31 PM

0 Responses to "Delete Top 100 Rows from SQL Server Tables"

Post a Comment