Solved

Sql add ID number - simultaneously

Posted on 2015-01-13
3
137 Views
Last Modified: 2015-01-14
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?
0
Comment
Question by:ukerandi
  • 2
3 Comments
 
LVL 69

Accepted Solution

by:
Qlemo earned 250 total points
ID: 40547869
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
 
LVL 45

Assisted Solution

by:Kent Olsen
Kent Olsen earned 250 total points
ID: 40547874
The autonumber (IDENTITY) column will manage that for you even if the two inserts appear to be simultaneous.


Good Luck,
Kent
0
 
LVL 69

Expert Comment

by:Qlemo
ID: 40547927
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

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question