Last_Insert_RowId SQL Function
The Last_Insert_RowId() function takes zero (0) argument and returns the ROWID of the last INSERT in the database for the current session.
Syntax Last_Insert_RowId()
/* Following will return last row id */
SELECT Last_Insert_RowId();
Note: You can also access this by .Net using Connection Object.LastInsertRowId property for faster access and without querying the database, it will be 0 if no inserts were made.