Assuming you are using SQL Server, you can use scope_identity to return the "last identity value inserted in the identifier column in Scope - this is a module: stored procedure, trigger, function or package. Therefore, the two statements are in the same scope if they are in the same stored procedure, function or batch. "
INSERT INTO Entrys ('Name','Description') VALUES ('abc','xyz'); SELECT SCOPE_IDENTITY()
source share