Solved

How delete all recods not in top 40

Posted on 2014-01-29
3
281 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
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 65

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
 

Author Comment

by:ethar1
ID: 39818489
0

Featured Post

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now