Solved

How delete all recods not in top 40

Posted on 2014-01-29
3
289 Views
Last Modified: 2014-01-29
Deat all,
How delete all recods not in top 40
delete NewsSYSNewsTags where @@ROWCOUNT>40 and NewsID=@NewsID order by WordWeight desc
0
Comment
Question by:ethar1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 15

Expert Comment

by:David L. Hansen
ID: 39818247
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
 
LVL 66

Accepted Solution

by:
Jim Horn earned 500 total points
ID: 39818249
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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question