Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8183911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T01:19:01+00:00 2026-06-07T01:19:01+00:00

According to MSDN, @@IDENTITY returns the last identity value generated for any table in

  • 0

According to MSDN, @@IDENTITY returns the last identity value generated for any table in the current session, across all scopes.

Has anyone come across a situation where this functionality was useful? I can’t think of a situation when you would want the last ID generated for any table across all scopes or how you would use it.

UPDATE:

Not sure what all the downvotes are about, but I figured I’d try to clarify what I’m asking.

First off I know when to use SCOPE_IDENTITY and IDENT_CURRENT. What I’m wondering is when would it be better to use @@IDENTITY as opposed to these other options? I have yet to find a place to use it in my day to day work and I’m wondering if someone can describe a situation when it is the best option.

Most of the time when I see it, it is because someone doesn’t understand what they were doing, but I assume Microsoft included it for a reason.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T01:19:03+00:00Added an answer on June 7, 2026 at 1:19 am

    In general, it shouldn’t be used. SCOPE_IDENTITY() is far safer to use (as long as we’re talking about single-row inserts, as highlighted in a comment above), except in the following scenario, where @@IDENTITY is one approach that can be used (SCOPE_IDENTITY() cannot in this case):

    • your code knowingly fires a trigger
    • the trigger inserts into a table with an identity column
    • the calling code needs the identity value generated inside the trigger
    • the calling code can guarantee that the @@IDENTITY value generated within the trigger will never be changed to reflect a different table (e.g. someone adds logging to the trigger after the insert you were relying on)

    This is an odd use case, but feasible.

    Keep in mind this won’t work if you are inserting multiple rows and need multiple IDENTITY values back. There are other ways, but they also require the option to allow result sets from cursors, and IIRC this option is being deprecated.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

According to MSDN BOL (Books Online) description on SOME | ANY (Transact-SQL) , SOME
C# 's BinaryReader has a function that according to MSDN, reads an integer encoded
According to MSDN is: The using directive has two uses: 1)To allow the use
According to MSDN The return value specifies the result of the message processing; it
according to MSDN, Visual Studio uses a special heap in debug mode that has
According to MSDN documentation it is not possible to set Socket.SendTimeout to a value
According MSDN, FxCop is an application that analyzes managed code assemblies (code that targets
According to MSDN , a hash function must have the following properties: If two
According to MSDN (Section 11.3.6 of the C# spec ): Within an instance constructor
According to MSDN Documentation for partial classes : Partial methods are implicitly private So

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.