Question

so I have a stored procedure (sql server 2008 r2) something like this

BEGIN TRAN
BEGIN TRY


   //critical section
    select value        
    update value
       //end of critical section


    COMMIT
END TRY
BEGIN CATCH
    IF @@TRANCOUNT > 0
        ROLLBACK
END CATCH

I want no two stored procedures read the same value. In other words read and update should be atomic. This code does this? If not how do I do it?

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top