Retrieves the next identity value that is available for the next insert.
next_identity(table_name)
identifies the table being used.
Updates the value of c2 to 10. The next available value is 11.
select next_identity ("t1") t1 -------- 11
next_identity returns the next value to be inserted by this task. In some cases, if multiple users are inserting values into the same table, the actual value reported as the next value to be inserted is different from the actual value inserted if another user performs an intermediate insert.
next_identity returns a varchar chararcter to support any precision of the identity column. If the table is a proxy table, a non-user table, or the table does not have identity property, NULL is returned.
The permission checks for next_identity differ based on your granular permissions settings.
Granular permissions enabled |
With granular permissions enabled, you must be the table owner, or be a user with select permission on the identity column of the table, or have manage database permission to execute next_identity. |
Granular permissions disabled |
With granular permissions disabled, you must be the database owner or table owner, or be a user with sa_role, or have select permission on the identity column of the table to execute next_identity. |