3

I have a regular table in SQL Server 2012 and I want to sort the data in a certain query by creation date of the records.

The problem is I don't have a column that holds this data for each record.

Is there a way of doing that without the designated column?

Maybe there is some kind of a built-in creation date information that exists in the database and I can access it somehow...

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
TheCuBeMan
  • 1,954
  • 4
  • 23
  • 35
  • 1
    If your table has an identity column which is also the table's clustered index. You may have some luck by sorting with that column. In general it will give you a good indication of the creation order. – Robert Sep 15 '15 at 22:40

2 Answers2

0

There is no built-in creation date information for rows.

There are some (commercial) tools that can sometimes extract that information from the transaction logs. That's a capability used in emergencies, not during normal operations.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
usr
  • 168,620
  • 35
  • 240
  • 369
0

If you don't have a date column, you cannot sort by created date. There is no built-in create date per row that I know of. You have some other options though. If you have an identity column (auto increment), you can order by that to find which row was added first.

You could perhaps use the location of the row in data pages like this answer mentions: Equivalent of Oracle's RowID in SQL Server

Community
  • 1
  • 1
zedfoxus
  • 35,121
  • 5
  • 64
  • 63