Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server : how to sort by creation date with no designated column

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...

like image 662
TheCuBeMan Avatar asked Dec 20 '25 13:12

TheCuBeMan


1 Answers

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

like image 147
zedfoxus Avatar answered Dec 23 '25 03:12

zedfoxus