I want create a Stored Procedure that insert data to 3 table using transactions.
I get the last primary key value of the Main table using MAX
. It takes a little time to get it.
My problem is here where some request come in same time and all of them get same result for last record. How can I lock transaction or other solution to it?
I know I can make an identity field and use it with SCOPE_IDENTITY
, but don't want do this, unless I'm forced to do it.