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 add the .NET MAUI App Accelerator in Visual Studio

 To add the .NET MAUI App Accelerator in Visual Studio, follow these steps: Prerequisites: Ensure you have Visual Studio 2022 (17.3 or lat...