Helping you build a better website
(and other interesting web stuff)

CSSHTMLJavaScriptjQueryMSSQLMySQLPHPSilvaTechnologiesWordpress
Silva Web Designs - Blog

How to delete the top ‘X’ rows from a table using SQL Server 2008?

To delete the top ‘X’ rows from a table using SQL Server 2008 / MSSQL for specific ordering criteria deleting from a CTE or similar table expression is the most efficient way.

This can be achieved as follows:-


;WITH CTE AS
(
SELECT TOP 1000 *
FROM [mytable]
ORDER BY a1
)
DELETE FROM CTE

We hope this has helped, feel free to check out other blogs for tutorial and helpful tips when it comes to the digital world. Have a project in mind? Awesome, get in touch with our team for assistance.

Nathan da Silva - Profile

Posted by: Nathan da Silva

Nathan is the Founder of Silva Web Designs. He is passionate about web development, website design and basically anything digital related. His main expertise is with WordPress, Magento, Shopify as well of many other frameworks. Whether you need responsive design, SEO, speed optimisation or anything else in the world of digital then get in touch. If you would like to work with Nathan, simply drop him an email at [email protected]

It’s good to share

Join the discussion