The identity function--can only be used in a SELECT INTO statement to simulate the role of the identity property when inserting data to generate self-growth values.
SELECT IDENTITY (int1,1 as id_num to newtable from oldtable;
IDENT_INCR function-Returns the auto-growth value of the table, for example, if we want to increase by 1 each time, the function returns 1.
UseAdventureWorks2012; GO SELECTTABLE_SCHEMA, TABLE_NAME,IDENT_INCR(Table_schema+ '.' +TABLE_NAME) as IDENT_INCR frominformation_schema. TABLESWHERE IDENT_INCR(Table_schema+ '.' +TABLE_NAME) is not NULL;
Ident_seed function--the initial seed value of the auto-grow column
UseAdventureWorks2012; GO SELECTTABLE_SCHEMA, TABLE_NAME,Ident_seed(Table_schema+ '.' +TABLE_NAME) as Ident_seed frominformation_schema. TABLESWHERE Ident_seed(Table_schema+ '.' +TABLE_NAME) is not NULL; GO
Ident_current-current autogrow value for the identity column of the table
UseAdventureWorks2012; GO SELECTTABLE_SCHEMA, TABLE_NAME, ident_current (Table_schema+ '.' +TABLE_NAME) as Ident_seed frominformation_schema. TABLESWHEREIdent_current (Table_schema+ '.' +TABLE_NAME) is not NULL; GO
Scope_identity ()--maximum autogrow value generated in the current module (stored procedure)
@ @IDENTITY-the maximum autogrow value generated in the current session
SQL SERVER->> identity-related functions