I'm trying to remove the need to explicitly lock a table with the following code but from reports I've been getting it may be possible that the parameter and value in the row are suffering from a race condition.
Declare @NextNumber Int;
Update
MyParameterTable
Set
NextNumber = NextNumber + 1,
@NextNumber = NextNumber + 1
Select @NextNumber As NextNumber;
Hopefully you can see it is just incrementing an integer and returning the result. I was under the impression that an update statement formatted in this manner would handle the necessary locks but as I say, it might be the case that the parameter is beign assigned outside of the update lock.
Can anyone throw some light on this and suggest an alternative?
Regards
Ryan