What is Scope_Identity() & Ident_Current() in Sql Server
SCOPE_IDENTITY(): It is useful when we
want to know that during inserting of a record what is the current ID value of
a row. Lets say we are inserting a record in Student table which contains a
column StudentId which is auto generated. So, in this scenario if we want to
know what will be the StudentId we can get it by using scope_identity(). It will return the last identity value
created in the current session.
Query:
select scope_identity()
//execute this after inserting the record.
IDENT_CURRENT(): It returns the last IDENTITY value produced in a table, regardless of the connection that created the value, and regardless of the scope of the statement that produced the value.
-
It is not limited by scope and session, it is limited to a specified table.
- It returns the identity value generated for a specific table in any session and
any scope.
If we want to know the last inserted record
in any table regardless of the scope then, execute following:
Query:
select IDENT_CURRENT('Student')as CurrentIdInserted
Note: scope_identity()
or IDENT_CURRENT('tablename')will
work only if the table has a column set with the property Identity Specification as Yes. e.g. RecordId
Dot Net is an ever trending technology where it is more preferable by developers to utilize the features in the dot net language. Your article on Dot Net language proves that it is an evergreen technology in the IT market.
ReplyDeleteRegards:
.asp.net training in chennai
.net training
This blog is really good I would like to say thanks please share more content on msbi online training
ReplyDeleteThanks for share this information. I have read your blog. Your information
ReplyDeleteis really helpful for me. Keep update your blog.
redbeardpress
Education
Thanks for share this.
ReplyDeletereally helpfull
Don’t Call Me Angel Lyrics
~ Regards Atolyricz
it was so good to read and useful to improve my knowledge as updated one, keep blogging.
ReplyDeletesap training in chennai
sap training in annanagar
azure training in chennai
azure training in annanagar
cyber security course in chennai
cyber security course in annanagar
ethical hacking course in chennai
ethical hacking course in annanagar
Thanks for any other wonderful post. Where else may just anyone get that type of info in such a perfect means of writing? I’ve a presentation next week, and I am on the look for such information.
ReplyDeletehadoop training in chennai
hadoop training in omr
salesforce training in chennai
salesforce training in omr
c and c plus plus course in chennai
c and c plus plus course in omr
machine learning training in chennai
machine learning training in omr
Excellent Blog! I would like to thank for the efforts you have made in writing this post.
ReplyDeleteI am hoping the same best work from you in the future as well. I wanted to thank you for this websites!
java training in chennai
java training in tambaram
aws training in chennai
aws training in tambaram
python training in chennai
python training in tambaram
selenium training in chennai
selenium training in tambaram
Bollywood Style Kurta Palazzo Set
ReplyDeleteCotton Anarkali Kurta Palazzo Set
Cotton Anarkali Dress
Designer Anarkali Suit
Designer Anarkali Suit Set
Partywear Salwar Kameez Suit
Flared Kurta Palazzo Dupatta Set
Green Anarkali Suit Set
Golden Gota Work Suit Set
Green Flared Kurta Palazzo Set
SMM PANEL
ReplyDeleteSMM PANEL
is ilanlari blog
instagram takipçi satın al
hırdavat
Https://www.beyazesyateknikservisi.com.tr
SERVİS
Tiktok Jeton Hilesi