Home All Groups Group Topic Archive Search About

What is the best SQL to always keep 50 latest rows in a table?

Author
14 Sep 2006 9:04 PM
Ding Yi Lin
Dear Sir,
    My db is sql2000, I have a table, which used as a queue for data
that will be fetched by client application per 1 sec. The data is just
to let user know what message has been processed.
There would be 3x equipment controller applications(EID) that will do
something , logging and insert message into the queue.
The Client application has a treeview with EID as treenode. The user
clicks the EID he wants to monitor and the client app will fetch the
EID related data from the table. Once fetched, the data will be
deleted from table. AS you will see, other EID will still insert data
into table and this will make the related EID data become bigger and
bigger. This is the reason I have to maintain each EID with latest 50
rows in table.

It's also possible that the table will be mysql by client request.

How to do this? I  didn't work out a elegant method to do this.

Best regards Peter

AddThis Social Bookmark Button