Contact Me

Nirav Prabtani

Mobile : +91 738 308 2188

Email : niravjprabtani@gmail.com

Nirav Prabtani

Monday 19 May 2014

Get last inserted row id from database


You can get latest generated id of a table in two ways..

1) Select top 1 id from a table and order by it desc like this..

 
SELECT TOP 1 id FROM TABLENAME ORDER BY DESC


2) You can use @@IDENTITY it gives latest inserted identity column like this..

INSERT INTO (.............)

SELECT @@IDENTITY





No comments :

Post a Comment