-- Step 1: (First Session) use TSQL2012 BEGIN TRAN; -- Step 3: (First Session) Update hr.Employees Set postalcode = N'10004' Where empid =1; -- Step: not sure if it is executed before or after step 4 of the other session. Commit tran;
Note: I know that perhaps a better method will be to use RCSI or some other isolation method. Here the idea is to discover if there is a way to add the requested IF/Else using SET TRANSACTION ISOLATED LEVEL UNCOMITTED.
-- Step 2: (Second Session) use TSQL2012 SET TRANSACTION ISOLATED LEVEL UNCOMITTED -- Step 4: (Second Session) -- Add TRY/CATCH or IF/ ELSE to determine whether -- the following select is comiited or still uncomitted -- or perhaps it is rolled back. IF @@TRANCOUNT <of First Session> >0 SELECT 'Committed Result: ' As Status, lastname, firstname, region FROM HR.Employees --<commited result returned: region=1004 for empid=1> ELSE SELECT 'Uncommitted Result: ' As Status, lastname, firstname, region FROM HR.Employees --<uncommited result returned: region=1004 for empid=1>
From novice to tech pro — start learning today.