employer cover photo
employer logo
employer logo

TechRAQ Info Solutions

Est-ce votre entreprise ?

Question d’entretien chez TechRAQ Info Solutions

How to find the last inserted id in SQL?

Réponse à la question d'entretien

Utilisateur anonyme

15 mai 2019

There are three ways in sql server to find out the last inserted id. 1. @@Identity will give last inserted ID but the problem is it is not a scope limited. In case there is a trigger acting on the table @@Identity will give the last inserted id of the trigger. 2. scope_identity will give the last inserted ID with in the scope 3. Identity_current(table_name) will give the Last Iserted ID of the the table_name passed as parameter