In C# we can make a set of operations atomic using locks:
lock (syncLock) { // Do something 1 // Do something 2 // ... } Now in T-SQL I want the same with a row. I should do some calculations and I want no change to the row until my calculations are finished. I know that the lock should be minimized and I did so.
Also the whole operation is read (no write) so there's no need for a transaction.
LOCK SELECT statement on a single row // Some calculations here... IF ... RETURN End of LOCK I know about ROWLOCK and I can use it with my select statement. But I need the lock for calculation lines also. Is there something like C# brackets in T-SQL or BEGIN LOCK, END LOCK just like Monitor enter/exit ?