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 and web site design. His expertise is WordPress & Magento as well as many other frameworks. Would you like to work with Nathan? Send him an email on [email protected]

It’s good to share

Join the discussion