previous | index | next

Determining Identity Column Values

You can determine the most recently assigned identity column value by using the built-in SQL function IDENTITY_VAL_LOCAL along with the VALUES statement.

In the customer example,

   VALUES IDENTITY_VAL_LOCAL();

produces:

Functions can be used in SQL queries where expressions are allowed. For example:

   SELECT name, address, balance FROM customer 
   WHERE id = IDENTITY_VAL_LOCAL();

produces:


previous | index | next