Retrieves the next identity value that is available for the next insert.
next_identity(table_name)
select next_identity ("t1") t1 -------- 11
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.
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 | Description |
---|---|
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. |
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. |