Icon LASTIDENTITY

Returns the last identity value assigned to the specified column in the specified table.

Syntax
LASTIDENTITY(<StringExpression>, <StringExpression>)

<StringExpression> = 

Type of:

CHARACTER|CHAR
CHARACTER VARYING|VARCHAR
GUID
CHARACTER LARGE OBJECT|CLOB

Returns
INTEGER

Usage
The LASTIDENTITY function returns the last identity value assigned to the specified column in the specified table. The table name is the first parameter to the function, and the column name is the second parameter to the function.

Warning This function only returns the last identity value assigned for the specified column for the current session. It does not reflect any identity values assigned to any other session for the same table. Therefore, if the current session has not inserted any rows in the specified table since the session was first logged in, then the value returned will be 0.

Examples
SELECT LASTIDENTITY('Customer', 'CustNo') AS LastCustNo

SQL 2003 Standard Deviations
This function deviates from the SQL 2003 standard in the following ways:

DeviationDetails
ExtensionThis function is an ElevateDB extension.
Image