How to get Last row (record) from a table
Here i will tell you how to get last row of a table, this is simple a trick ,
In this example i have created temporary table,first i have created a table
then i have inserted some records into #student table
CREATE TABLE #STUDENT(ID BIGINT IDENTITY,FULLNAME NVARCHAR(MAX),AGE INT,GENDER CHAR(1),STATUS BIT DEFAULT(0))
insert some records into #student table
INSERT INTO #STUDENT VALUES('Aamir Hasan',25,'M',0)
INSERT INTO #STUDENT VALUES('Aamir Hasan',24,'M',0)
INSERT INTO #STUDENT VALUES('Saida Hasan',23,'F',0)
INSERT INTO #STUDENT VALUES('Aamir Hasan',22,'M',0)
INSERT INTO #STUDENT VALUES('Saba Hasan',21,'F',0)
Select all records from #student table
SELECT * FROM #student
now here you can get last record from below query.
SELECT TOP 1 * FROM #student ORDER BY id DESC
after all step drop #student table
DROP TABLE #student