This question is already an answer here
- 9 replies
this disturbed me The day I am doing, I have a table with automatic increment, which I want is that the value of the pay scale will be put in the same line. The problem is that when concurrent users are reaching the query, this will not copy the correct value
below is my table:.
CREATE TABLE tblTransactions (dctransno INT identity primary key, vcDescription VARCHAR, dcTransNoCopy INT zero, user VARCHAR)
and my queries:
< Pre> start TRAN INSERT INTO tblTransactions (dctransno, user) value (@VcDescription, @ User); Set @identity = @@ identification - identity update tblTransactions SET dcTransNoCopy = @identity Where dcTransNo = @identity and user = @user, - insert COMMIT TRAN
What do I achieve I want to have an example of a grouped transaction given below. The problem is that my query above does not take ownership. Assuming USERA and UserB are using the system together:
dcTransNo Description dcTransNoCopy User 1 Transaction1 1 USERA 2 Transaction2 1 USERA 3 Transaction3 1 USERA 4 Transaction1 3 UserB --- & Gt; Not correct, ClonetransNo value for UserBo 4 not 3.
Please help, thanks in advance.
You must use SCOPE_IDENTITY () instead of @@ identification
More Information
Comments
Post a Comment