Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Tassadar
Starting Member
1 Post |
Posted - 2009-08-28 : 05:08:15
|
| Hi all, sorry if this has been gone over before but i have the following problem.I need to insert data into a table where the primary key is just a sequence that goes up by 1 each new record. This must be done manually in the program though as it is not set as Identity(and i can't change this as 3rd party app).When i insert a new row i need to use that value for primary key to insert data into a second table also. My thoughts on how to do wereSelect max value +1 from tableInsert records using this new value to table 1Insert records using this new value to table 2My problem is that between my select statement and the insert, the program(which has multiple users) could have inserted more records which would cause the inserts to fail.I thought about locking the table, but have been told that affects performance, so is there any other way to do this? or is locking the only option?Any help greatly appreciated.Andy |
|
|
|
|
|