A  B  C  D  E  F  G  H  I  J  K  L  M  N  O  P  Q  R  S  T  U  V  W  X  Y  Z  special characters  sybase-tech-blog


Category: ASE: Functions: System Functions

next_identity()

The system function next_identity() returns the next possible value for inserts into a table with identity column. This value can vary from the eventually inserted value if several users attempt to insert into the same table at the same time. The return value of the function next_identity has the datatype varchar, to reflect all possible precision values of the identity column. If the table to be queried is a proxy table, not a user table, or if the table does not contain an identity column, the return value is NULL. The function is related to the configuration option "identity grab size". If the value of this option is "1", the next possible identity value for an "insert" statement of any session is returned. If the value of "identity grab size" is greater than "1", the return value is related to the "insert" statement of the current session. The function is executable only for the owner of a table, a System Administrator, or a Database Administrator.

Syntax of the System Function next_identity()

    next_identity("table_name")
    

The parameter of the System Function next_identity()

"table_name"
The parameter "table_name" specifies the name of the table, for which the next possible identity value shall be determined. The name of the table is stored in the column "name" of the system table sysobjects, or can be retrieved using the stored procedure sp_help.

Example for the System Function next_identity()

    select next_identity ('mytable')
go
mytable
--------
22

Depending on the current value of the configuration parameter "identity grab size", the return value (22) is the next possible identity value either for the current session or for any session.

See also:
sp_help

See also:

ASE T-SQL - Aggregate Functions,
audit_event_name(),
col_length(),
col_name(),
curunreservedpgs(),
datachange(),
datalength(),
data_pages(),
data_pgs(),
db_id(),
db_name(),
host_id(),
host_name(),
identity(),
index_col(),
index_colorder(),
isnull(),
lct_admin(),
license_enabled(),
lockscheme(),
object_id(),
object_name(),
pagesize(),
pointer_size(),
ptn_data_pgs(),
reserved_pages(),
reserved_pgs(),
rowcnt(),
row_count(),
showplan_in_xml(),
syb_sendmsg(),
syb_sendmsg(),
System Functions,
tempdb_id(),
tran_dumpable_status(),
tsequal(),
used_pages(),
used_pgs().