I have a web api web service that calls an authentication stored procedure. This stored procedure calls a different stored procedure that does 1 update:
UPDATE AccountLicensingDeviceConnectionsPerPeriod SET DateLastConnected = GETDATE(), ConnectionPermitted = @IsValid WHERE AccountId = @AccountId AND UserId = @UserId AND Device = @Device
And then does a different update:
UPDATE Users SET DateLastLoggedIn = GETDATE(), LastLoggedInDevice = @Device, InvalidLoginCount = 0 WHERE Id = @UserId
These updates are always in the same order or at least they should be, is there any way to avoid 2 concurrent processes to deadlock?
The deadlock graph: Deadlock graph data extracted
AuthenticateUser SP - h**ps://dl.dropboxusercontent.com/u/204180/AuthenticateUser.sql