473,408 Members | 1,772 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Need a fixed-length table

Hi,

Question from a rank beginner:

I need to create tables with a fixed number of rows, lets say 50. When a new row of data is added, the oldest entry disappears. I don't care what happens to the old data, I just need the latest 50.

It would be nice if this could be done without too much overhead. If you can think of more than one way of doing this it would be helpful.

The tables will be used by a web server that will display operational "dashboard" data from various systems.

Thank you for your help,
SimonPure
Jan 18 '07 #1
4 1092
almaz
168 Expert 100+
It's not a recommended pattern for SQL programming. If you want to get latest 50 records, just create a view that selects 50 latest records, and use simple insert statements.
Expand|Select|Wrap|Line Numbers
  1. create view dbo.vGetLast50
  2. as
  3.     select top 50 ID, inserted_date, description
  4.     from table_name
  5.     order by inserted_date desc
Jan 19 '07 #2
iburyak
1,017 Expert 512MB
If you still insist on your original request do following:


[PHP]Delete from table_name where ID not in
(select top 50 ID
from table_name
order by inserted_date desc)[/PHP]
Jan 19 '07 #3
Gentlemen,

Thank you for your advice. We're going to try with SQL, but I'll tell my people that it may not be the best approach.

--SimonPure
Jan 19 '07 #4
iburyak
1,017 Expert 512MB
Good Luck.
Jan 19 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Paul Trautwein | last post by:
I'm trying to get an image to float in a window despite scrolling. I've gotten it to work on my Mac using IE 5.2, Netscape, and Safari, but it goes wonky when I test it on a PC. (testing with IE...
6
by: Mason A. Clark | last post by:
Masters: On two or three-column layouts, one column often has a list of links. Scrolling the page hides them. I'm aware there's supposed to be the ability to fix the column (frame-like). I...
2
by: hq105862 | last post by:
Hi, Is it possible to simulate frames behaviour with CSS? Currently, I've used CSS to create the visual look of my old framed site. For this I've used styles that place the images at absolute...
9
by: pout | last post by:
What are the purposes of fixed-point? When should it be used? I read: #define Int2Fixed(x) (((long)(short)x) << 16) and the fixed-point in 16.16 format. Does the 16 in the MACRO refer to...
22
by: macAWM | last post by:
Hi list, First let me explain that my background is in Java and I am quite spoiled to its niceties (read "less ambiguous nature"). Anyway to my problems. 1. I want to write my own library for...
4
by: phillip.s.powell | last post by:
UPDATE redesign.student SET student_work_area_other SELECT REPLACE('anywhere,(.*)', '$1', i.work_area) AS regexp_col FROM mycompany.interns i, redesign.student s WHERE i.unique_key = s.unique_key...
13
by: Ikke | last post by:
Hi everybody, I've downloaded a design from www.oswd.org and have started rewriting the css and html to end up with a new design for my site. So far so good, but there are a few problems I...
1
by: O.B. | last post by:
In the example below, I'm trying to convert a fixed byte array to a string. I get an error about needing to use "fixed" but I have no clue where to apply it. Help? using System; using...
1
by: mb | last post by:
I know this sounds strange, but I have set up a dataview with a fixed header, so the header does not scroll up with the rows of data. However, I need the header to scroll horizontally (not...
15
by: ingejg | last post by:
I am starting to study internet synchronization, and my head is still spinning since internet is not my forte, however my boss is breathing down my neck at the moment. Our company has only one...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.