How to get the last inserted record from table in sql server

Posted by Jitendrasoft09 under C# on 6/26/2013 | Points: 10 | Views : 1047 | Status : [Member] [MVP] | Replies : 2
Hi All,
I want to understand How to get the last inserted record from table in sql server, let me know if anybody knows.

Jitendra Kumar
If my post helps you, plz mark as an answer.



Responses

Posted by: Satyapriyanayak on: 6/26/2013 [Member] [MVP] Silver | Points: 25

Up
0
Down
SELECT TOP 1 EmpId FROM EmployeeDetails ORDER BY EmpId DESC

SELECT MAX(EmpId) FROM EmployeeDetails

If this post helps you mark it as answer
Thanks

Jitendrasoft09, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: perfectchourasia-9163 on: 6/27/2013 [Member] Starter | Points: 25

Up
0
Down
While Creating Table Please make Id Column and then Co to Column properties Yes in Identity Specification.
after that

USE Above query

SELECT MAX(EmpId) FROM EmployeeDetails

ER sandeep chourasia
sandeepchrs@yahoo.com (on facebook)
http://www.aspnetcodes.com/

Jitendrasoft09, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response