Print Page | Close Window

just save N record to database ...

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=20647
Printed Date: 29 March 2026 at 8:42am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: just save N record to database ...
Posted By: miladanimator
Subject: just save N record to database ...
Date Posted: 12 July 2006 at 5:45am
hi all!

I write a shout box in asp + ms sql server database ...

and now I need a code that help me too :

I want to save just last 25 records in the database and other recordes delete automatically ...

I mean : when a user add a new sout in box , this shout add too the database and an old shout delete from database ...



Replies:
Posted By: michael
Date Posted: 14 July 2006 at 4:37pm
Assuming you are using SQL2k5 you can use a Derived Table with the new Row_Nubmer Function. I am sure there are other ways but this one is simple. You may have to tweak it to make it work fo you


With deleteOver AS
(Select ID, Row_Number() OVER (Order by ID DESC) as RowNumber from myTable)
Delete from deleteOver where RowNumber > 25

-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net