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.
| 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---------message1message2message3message4message5message6message7message8message9message10now i want to delete first record and insert a record at endthen table should looks as follows.Status---------message2message3message4message5message6message7message8message9message10message11Please help me what Query should i write to solve this problem in "SQL Server".Urgent please.thanksNagulmeera" |
|
|
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 etcHope this helps.------------->>> BREAKING NEWS!!! <<<------------- Saddam Hussien has weapons of mass destrcution |
 |
|
|
|
|
|