0

I need to select a table sorted as a "Queue", the least recent to most recent row. Exists something feature that enable me to do this?

gbn
  • 408,740
  • 77
  • 567
  • 659
wallybh
  • 862
  • 1
  • 11
  • 27

3 Answers3

3

At the very least, if you have an IDENTITY/AUTONUMBER, or at least a DATE to sort by you could

SELECT *
FORM Table
ORDER BY DateColumn

Or

SELECT *
FORM Table
ORDER BY IDColumn
Adriaan Stander
  • 156,697
  • 29
  • 278
  • 282
  • Just keep in mind that there is no guarantee that IDENTITY columns will be in sequential order of the time at which they were inserted – Tom H Jan 19 '10 at 18:31
  • Aggreed, but with no structure provided, this should cover some of th OP's possibilities. – Adriaan Stander Jan 19 '10 at 18:36
1

You need at least a column that represent a moment in time, like a date column. Then you order by that field:

SELECT * FROM Employee ORDER BY BirthDate
Pierre-Alain Vigeant
  • 21,915
  • 8
  • 62
  • 101
0

If you don't mean "ORDER BY", do you mean use a table as concurrency-safe message queue?

Like this: SQL Server Process Queue Race Condition?

Community
  • 1
  • 1
gbn
  • 408,740
  • 77
  • 567
  • 659