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

Open default email app in .NET MAUI

Sample Code:  if (Email.Default.IsComposeSupported) {     string subject = "Hello!";     string body = "Excellent!";    ...