How can I query data in the order it was created?
I don’t have a date-created field in this table.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you don’t have a field storing the time of insertion, or any other meta-data regarding the order of insertion, there is no reliable way to get this information.
You could maybe depend on a clustered index key, but these are not guaranteed. Neither are
IDENTITYfields or other auto-generated fields.To clarify, an
IDENTITYfield does auto-increment, but…IDENTITY_INSERTIf the ID field is your PK, you can probably use that to get a rough idea:
Per your comment, the field is a
GUID. In that case, there is no way to return any sort of reliable order sinceGUIDs are inherently random and non-sequential.