Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How delete all recods not in top 40

Posted on 2014-01-29
3
Medium Priority
?
292 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 2000 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

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 article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

721 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