Saturday, September 3, 2011

SQL SERVER - How to get the last generated value of an identity column

SCOPE_IDENTITY Returns the last IDENTITY value inserted into an IDENTITY column in the same scope(a stored procedure, trigger, function, or batch).


Example:

Insert Employees(FirstName, LastName) values ('Sharma','Bhupesh')

select @@identity Employees
SCOPE_IDENTITY, IDENT_CURRENT, and @@IDENTITY are similar functions in that they return values inserted into IDENTITY columns

No comments:

Post a Comment

How to upload app to macOS

1. Open Terminal Press Cmd (⌘) + Space , type Terminal , and hit Enter . 2. Navigate to Your Build Output Directory Your .app file is likel...