How delete all recods not in top 40

Deat all,
How delete all recods not in top 40
delete NewsSYSNewsTags where @@ROWCOUNT>40 and NewsID=@NewsID order by WordWeight desc
ethar1Asked:
Who is Participating?
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
Air code.  I do my own stunts too..

DELETE FROM NewsSYSNewsTags
WHERE NewsID NOT IN (
   SELECT TOP 40 NewsID FROM NewsSYSNewsTags ORDER BY WordWeight DESC)
0
 
David L. HansenProgrammer AnalystCommented:
When you say "Top 40" to you mean by ranking (like the top 40 highest net worth) or just the first 40 records entered into the table?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.