How to get last inserted record id from table?

We have two ways:

First one is:

SELECT SCOPE_IDENTITY()

We write above line just after the insert query. Then it will return the last inserted record’s identity column value.

Second one is:

SELECT IDENT_CURRENT('OrderMaster')

We can write above line any where in the query window. This is will return last inserted record of specific table. Here OrderMaster is the table name in the database.

Leave a Comment

Your email address will not be published. Required fields are marked *