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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T23:41:57+00:00 2026-05-10T23:41:57+00:00

I was previously getting the next available autonumber used in Access by doing a

  • 0

I was previously getting the next available autonumber used in Access by doing a simple query like so:

SELECT RecordNumber, Info  FROM myTABLE  WHERE 0 = 1 

This way I could create a variable to hold the currentRecord and it will use the same autonumber that Access was going to use when I was updating the row

Example

rs.AddNew currentRecord = rs('RecordNumber')  rsInfo = 'SomeFormData' & currentRecord rs.Update rs.Close 

Now this use to work on MS Access, but in SQL Server 2005, I am not getting back the Identity created by the new record. ‘SomeFormData’ is been inserted correctly, the RecordNumber field in SQL is been populated by the new auto number but I don’t have the RecordNumber in my variables and I need it to continue filling related forms, that save data to related tables and need to save the currentRecord number.

Question: is there a way to get this unique number back when doing a new insert?

  • 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. 2026-05-10T23:41:57+00:00Added an answer on May 10, 2026 at 11:41 pm

    IDENT_CURRENT('tableName') (include the single quotes) returns the current value of the identity for the given table. This value should be the last-assigned identity value used in the table. In other words, you will have a row with this identity value already in the table, unless that row has been deleted. The identity value that will be assigned on the next INSERT will be IDENT_CURRENT('tableName') + IDENT_INCR('tableName').

    I don’t recommend relying on this, though. If you pre-determine the next identity value this way, you’re bound to end up in a situation where another process makes the insert that actually gets that ID before yours does, so your process ends up using the wrong ID value.

    It’s much better to make your insert first (even if you don’t have all the data yet), and use SCOPE_IDENTITY() to get the actual ID assigned.

    You might wonder why SCOPE_IDENTITY() is better than IDENT_CURRENT('tableName'). As the name implies, the former will give you that most recent identity value assigned within your current scope (your batch, your stored proc, whatever), whereas the latter will give you the most recent identity assigned on the table, by anyone. Even though you might call IDENT_CURRENT right after ‘INSERT, it’s still possible that someone else’s INSERT occurs in between, and IDENT_CURRENT will give you the identity value that resulted from their insert instead of yours, whereas SCOPE_IDENTITY will always give you yours.

    EDIT:

    It’s also worth mentioning that SCOPE_IDENTITY() is favored over the similarly-functioning @@IDENTITY. While both return the latest identity value assigned within the current batch, @@IDENTITY is affected by inserts that occur within triggers; SCOPE_IDENTITY() is not.

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

Sidebar

Ask A Question

Stats

  • Questions 123k
  • Answers 123k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Your issue is your trying to chain the bind to… May 12, 2026 at 12:59 am
  • Editorial Team
    Editorial Team added an answer You'd have to use reflection: Type type = myObject.GetType(); FieldInfo… May 12, 2026 at 12:59 am
  • Editorial Team
    Editorial Team added an answer I prefer classes, but if I have to use records,… May 12, 2026 at 12:59 am

Related Questions

I'm writing a game, and I want to model its different states (the Game
I have a Java program that runs many small simulations. It runs a genetic
At my workplace, the traffic blocker/firewall has been getting progressively worse. I can't connect
I'm creating a windows service and after installing the service, it stops and starts

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.