Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

implementing a FIFO stack

Status
Not open for further replies.

Funka

Programmer
Jun 11, 2001
105
US
hello! i am wondering what is the fastest, most efficient way to implement a FIFO stack in SQL Server 7...?

for example, i have a table called ActiveTasks, and need stored procedures to read/remove the topmost Task, and then another which adds a new task to the bottom of the stack.

i have been thinking to implement a second table with a pointer to the last used Task's ID combined with sorting the ActiveTasks table by the Identity column, but am not so sure this is the most efficient way. thanks for any advice!
 
i would like to add that using the Identity column to sort the stack will not be an option, as we will be clustering our SQL servers, and the Identity inserted by any machine will not necessarily be sequential... thanks again!
 
how about just adding a datetime column with a default of getdate()
then just retrieve the task with the oldest date.

just doing an insert will conceptually go to the bottom of the stack, since you will retrieve the first in by
selecting the top 1 from stack order by datetimefield

also your processing procedure will need to delete the record from the stack when it is done with it.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top