Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 How to insert a record at the BOF and delete from EOF in table

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-01-13 : 07:48:55
nagulmeera writes "Hai all,

I am facing a problem in my application.
my prblem is i want to insert at most 10 records in a table and when the table filled with 10 records i want to delete the first record and insert a new rercird at the end of the table.initially the table contain Zero records.

when the table filled with 10 records it looks as follows.


Status
---------
message1
message2
message3
message4
message5
message6
message7
message8
message9
message10

now i want to delete first record and insert a record at end

then table should looks as follows.

Status
---------
message2
message3
message4
message5
message6
message7
message8
message9
message10
message11


Please help me what Query should i write to solve this problem in "SQL Server".
Urgent please.

thanks
Nagulmeera"

Amethystium
Aged Yak Warrior

701 Posts

Posted - 2005-01-13 : 09:52:51
Sorry if I am unable to give you a working query but I will share my initial thoughts regarding your problem.

You will need to implement a trigger which will fire when an INSERT event takes place. The trigger should perform a count of number of messages in the table. If the count is less than 10 then perform insert. If the count equals 10 then you will need to perform an update instead.

There is no beginning or end in a table as it is you who determines it by your ordering criteria. I suggest you add an extra sequential (identity) column 1-10 and then you can right an update query to shift the messages upwards to make the last one available for update so that mmessage1 becomes message2 and message 2 becomes message 3 etc

Hope this helps.

------------->>> BREAKING NEWS!!! <<<-------------
Saddam Hussien has weapons of mass destrcution
Go to Top of Page
   

- Advertisement -