J
Jonathan Wood
I posted earlier about the best way to add to a field value, and preventing
situations where the value could change between the time I read it and the
time I write the modified value. Some suggestions included using a
serializable transaction, and using the WHERE statement, which makes sense.
However, while looking into this, I came up with another, simpler syntax,
that I wonder if it eliminates concurrency issues. It looks like this:
CREATE PROCEDURE dbo.mc_Trainers_AddCredits
@TrainerId uniqueidentifier,
@Credits int
AS
BEGIN
SET NOCOUNT ON
UPDATE mc_Trainers SET Credits=(Credits+@Credits) WHERE UserID=@TrainerId
RETURN
END
Can anyone tell me if updating a field in a single UPDATE statement this way
eliminates concurrency issues?
Thanks.
situations where the value could change between the time I read it and the
time I write the modified value. Some suggestions included using a
serializable transaction, and using the WHERE statement, which makes sense.
However, while looking into this, I came up with another, simpler syntax,
that I wonder if it eliminates concurrency issues. It looks like this:
CREATE PROCEDURE dbo.mc_Trainers_AddCredits
@TrainerId uniqueidentifier,
@Credits int
AS
BEGIN
SET NOCOUNT ON
UPDATE mc_Trainers SET Credits=(Credits+@Credits) WHERE UserID=@TrainerId
RETURN
END
Can anyone tell me if updating a field in a single UPDATE statement this way
eliminates concurrency issues?
Thanks.