After discovering the pot of gold that is ServerFault's What are the canonical answers we've discovered over the years?, I'm inclined to think could do with the same.

If agreeable to moderators and contributors alike, please edit your nominations for canonical question/answer pairs into the community-wiki post below.

+1 - Great idea, and I know we have a number of them. –  JNK Jun 3 '12 at 3:08

1 Answer 1

"How do I get the rows from a table in the order they were inserted?": in the general case you simply can't, rows are not stored in any way that is guaranteed to reflect insert order over time. If the table has (and always has had) an automatically incrementing integer ID column that has never been tampered with (i.e. with SET IDENTITY_INSERT ON in MSSQL) then it can be used for this purpose, but such a column is no use for this purpose if retroactively added. Some databases may have an internal row id that operates as above exposed so you can use it for ordering, but I can't name any that do. –  David Spillett Jan 4 '13 at 16:14
(sorry if adding that as a comment is inappropriate, but I couldn't see a question in to hang it off and adding it to the list in the answer above would have been quite a diversion from the existing format) –  David Spillett Jan 4 '13 at 16:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .