Ident_current returns the last generated id value for any session and specific tables in any scope.
ExampleCode:
================================
Alter procedure [DBO]. [pr_test]
@ TXT as varchar (100 ),
@ Last as int output
As
Begin
Declare @ SQL varchar (100)
Insert into [tb_txt] (txt) values (@ txt)
Set @ last = cast (ident_current ('tb _ TXT ') as INT)
End
================================
@ Identity returns the last generated id value for any table in all scopes of the current session.
Scope_identity returns the last generated id value for the current session and any table in the current scope.
================================
Alter procedure [DBO]. [pr_test]
@ TXT as varchar (100 ),
@ Last as int output
As
Begin
Declare @ SQL varchar (100)
Insert into [tb_txt] (txt) values (@ txt)
Set @ last = cast (scope_identity () as INT)
End
================================