User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the MS SQL section within the Web Development category of DaniWeb, a massive community of 425,822 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,990 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MS SQL advertiser: Programming Forums
Views: 918 | Replies: 1
Reply
Join Date: Jun 2007
Posts: 17
Reputation: guptaalok12 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
guptaalok12 guptaalok12 is offline Offline
Newbie Poster

Delete top 5 rows from a table

  #1  
Jul 12th, 2008
How to Delete top 5 rows from a table
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Mar 2007
Posts: 18
Reputation: wujtehacjusz is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 7
wujtehacjusz's Avatar
wujtehacjusz wujtehacjusz is offline Offline
Newbie Poster

Re: Delete top 5 rows from a table

  #2  
Jul 14th, 2008
You will need to be able to order the data in some way.

Say you have a table T storing people birthdays with two following columns: personId, birthdayDate.

To delete 5 top rows from that table you could do

  1. DELETE FROM T
  2. WHERE personId IN (SELECT top 5 personId FROM T ORDER BY personId)

I don't know if there is a better way of doing this.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb MS SQL Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the MS SQL Forum

All times are GMT -4. The time now is 4:20 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC