Sql add ID number - simultaneously

I alreday created Automatic number generate
For example
HR00001

I need to know if one user open form it will need to generate HR00001 and same time another user open the page need to create HR00002. any one have any idea appriciate, may be example?
I thought may be use LOCK but confusing how to do that?
LVL 10
ukerandiAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
QlemoConnect With a Mentor Batchelor, Developer and EE Topic AdvisorCommented:
The only way to get that working with autonumber is by inserting an "empty" row when the form is opened, and read the autonumber in to know which row to update.
If the form is cancelled (if available), the newly created empty row needs to get deleted or invalidated.
0
 
Kent OlsenConnect With a Mentor Data Warehouse Architect / DBACommented:
The autonumber (IDENTITY) column will manage that for you even if the two inserts appear to be simultaneous.


Good Luck,
Kent
0
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
Kdo is correct if you do not need the autonumber in the form, which I assumed. In that case you do not need to care, as he said.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.