The processing method adds an identity ID int identity to a field, three ways to create the identity and a comparison: in SQL Server 2000, there are three similar features: they are: scope_identity, Ident_ Both the current and @ @IDENTITY return values that are inserted into the IDENTITY column. Ident_current returns the identity value that was last generated for any session and for a particular table in any scope. Ident_current is not subject to scope and session restrictions, but is limited to the specified table. Ident_current returns the value generated for a specific table in any session and scope. @ @IDENTITY Returns the identity value that was last generated for any table in all scopes of the current session. Scope_identity returns the last identity value generated for the current session and any tables in the current scope, scope_identity and @ @IDENTITY return the last identified values generated within any table in the current session. However, scope_identity only returns the value inserted into the current scope, and the @ @IDENTITY is not restricted to a specific scope. AJQC Experiment: (40 local thread, 40+40 remote thread Concurrent test, insert 1200W Line), the conclusion is: 1. In a typical cascade application. Cannot use @ @IDENTITY, in the cii850,256m SD machine on the 1W more rows will be concurrently rushed More than 6,000 rows on p42.8c,512m DDR. 2.scope_identity () is absolutely reliable, can be used in stored procedures, even the trigger is not built, no concurrency conflict Select ident_current (' TableName ')--Returns the last marked value generated in the specified table select IDENT_INCR (' TableName ')--Returns the increment value of the marked field for the specified table select Ident_seed (' TableName ')-- Returns the indicated field seed value of the specified table returns the AutoNumber of the last inserted record select Ident_current (' TableName ') returns the next AutoNumber: Select Ident_current (' TableName ') + (select IDENT_INCR (' TableName ')) SELECT @ @IDENTITY--Returns the last value generated in all tables in the current session
SQL returns the ID of the data you just inserted