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?
Asked
Active
Viewed 124 times
0
-
4You need to show the table structure, and what defines it as being first...last. – Adriaan Stander Jan 19 '10 at 18:24
3 Answers
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
- 162,879
- 31
- 289
- 284
-
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
- 22,635
- 8
- 65
- 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?