Q:

How to find last inserted row in SQL server without identity column

I have created table like below: 
create table EmployeeDetails
(
    id int,
    name varchar(50),
    designation varchar(50),
    ReportingTo int
)

And inserted rows like this:
insert into EmployeeDetails values(1, 'A', 'Developer', 3)
insert into EmployeeDetails values(5, 'E', 'CEO', 5)
insert into EmployeeDetails values(2, 'B', 'Developer', 3)
insert into EmployeeDetails values(3, 'C', 'Manager', 4)
insert into EmployeeDetails values(4, 'D', 'S.Manager', 5)

My question is: how can I identify the last inserted row in the table?
Used queries:
select IDENT_CURRENT('EmployeeDetails')
Select SCOPE_IDENTITY()

But I still didn't find the answer.
Replies are always welcome

A:

This is too long for a comment.
You have a fundamental misunderstanding of tables in relational databases.  They represent unordered sets.  So, there is no "last row" in a table.  The information on the ordering of rows has to be included when you create the table and/or load data into it.
In SQL Server, the simplest method is an identity column.  That is why many tables are defined as:
create table EmployeeDetails (
    id int identity primary key,
    name varchar(50),
    designation varchar(50),
    ReportingTo int
);

You can also add default insertion time columns:
create table EmployeeDetails (
    id int identity primary key,
    name varchar(50),
    designation varchar(50),
    ReportingTo int,
    CreatedAt datetime default gettime()
);

However, you can have multiple rows with the same datetime value.

A:

Add fields of type datetime with name CreateDate and UpdateDate in your table, when you insert record in your table set their value for getdate()
After that you can run queries:
Select top 10 * from YourTable Order By CreateDate DESC

Or for last updated
Select top 10 * from YourTable Order By UpdateDate DESC

A:

You also can use rowversion like below,if you add a column
CREATE TABLE MyTest (myKey int  
    ,myValue int, RV rowversion);  
GO   
INSERT INTO MyTest (myKey, myValue) VALUES (1, 0);  
GO   
INSERT INTO MyTest (myKey, myValue) VALUES (2, 0); 

select * from mytest order by rv desc

Note:
This always give the last row inserted/Updated 
References:
rowversion 

