![Cscope Windows](https://kumkoniak.com/105.jpg)
This was the last insert that occurred in the same scope. SCOPE_IDENTITY() returns the IDENTITY value inserted in T1. returns the last identity column value inserted across any scope in the current session. This scenario illustrates two scopes: the insert on T1, and the insert on T2 by the trigger.Īssuming that both T1 and T2 have identity columns, and SCOPE_IDENTITY return different values at the end of an INSERT statement on T1. When a row is inserted to T1, the trigger fires and inserts a row in T2. However, SCOPE_IDENTITY returns values inserted only within the current scope is not limited to a specific scope.įor example, there are two tables, T1 and T2, and an INSERT trigger is defined on T1. SCOPE_IDENTITY and return the last identity values that are generated in any table in the current session. For more information, see IDENT_CURRENT (Transact-SQL). IDENT_CURRENT returns the value generated for a specific table in any session and any scope. IDENT_CURRENT is not limited by scope and session it is limited to a specified table. SCOPE_IDENTITY, IDENT_CURRENT, and are similar functions because they return values that are inserted into identity columns.
![Cscope Windows Cscope Windows](https://freesoft.ru/storage/images/85/849/84813/84813_thumb.png)
![Cscope Windows Cscope Windows](https://windows-cdn.softpedia.com/screenshots/thumbs/Cleverscope-thumb.png)
To view Transact-SQL syntax for SQL Server 2014 and earlier, see Previous versions documentation.
![Cscope Windows](https://kumkoniak.com/105.jpg)