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 8635605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:01:02+00:00 2026-06-12T10:01:02+00:00

I would like to retrieve the latest inserted or even updated identity from a

  • 0

I would like to retrieve the latest inserted or even updated identity from a table. But whenever I write the following code there is no results at all.

select * 
from PersonHowEducation prh 
inner join HowzeEducation he on prh.HowzeEducationId = he.HowzeEducationId
where he.HowzeEducationId = @@IDENTITY

What shall I really do ?

  • 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-12T10:01:03+00:00Added an answer on June 12, 2026 at 10:01 am

    If this were part of a batch script, and you have only just inserted it in the same session, then you would use SCOPE_IDENTITY() to retrieve the last inserted HowzeEducationId value.

    select * from PersonHowEducation prh inner join HowzeEducation he on 
          prh.HowzeEducationId=he.HowzeEducationId
          where he.HowzeEducationId=SCOPE_IDENTITY()
    

    However, if this is from a completely different session, one that DID NOT JUST perform the insert, then you can get the last record inserted using

    select * from PersonHowEducation prh inner join HowzeEducation he on 
          prh.HowzeEducationId=he.HowzeEducationId
          where he.HowzeEducationId=(select top(1) HowzeEducationId from HowzeEducation
                                     order by HowzeEducationId desc)
    

    Note: There could be rare cases where an identity insert does not create the largest id in the table, for example if someone decided a table should have 1 record of id= 1,000,000,001 and manually reseeded the identity back to 10,001.

    Another alternative, which may fizz if it is possible for the record to be deleted after insertion.

    select * from PersonHowEducation prh inner join HowzeEducation he on 
          prh.HowzeEducationId=he.HowzeEducationId
          where he.HowzeEducationId=(SELECT IDENT_CURRENT('HowzeEducation'))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to retrieve some columns from a table, without the id column,
I would like to retrieve a particular column from a table when the values
I would like to retrieve the AppSetting key from the assembly config file called:
I would like to retrieve an ordered query result, but I need to have
I am adding data to my database, but would like to retrieve the UnitID
Would like to know the c# code to actually retrieve the IP type: Static
Basically, I would like to include my latest Wall posting on my website. But,
I would like to retrieve the original file name from a website while downloading
I would like to understand how to retrieve the quotation from a top level
I would like to retrieve the html contents of the tinymce area, but without

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.