Click to See Complete Forum and Search --> : Trnasactions locks in MS SQL


stardv
January 27th, 2005, 02:50 PM
I have read up about transactions a little. I am just confused in one part. I just want to make sure I understand it right.

Will this code solve the problem:

SET TRANSACTION ISOLATION LEVEL REPEATABLE READ
GO
BEGIN TRANSACTION
SELECT * FROM Mytable with (rowlock)
UPDATE Mytable ....
...
COMMIT TRANSACTION

lets say if some other thread with transaction #2 is trying ot access the record being accessed by transaction #1 before it is committed, will it throw an error, or transaction #2 will be placed in queue until record gets unlocked.
selected in the transaction #1

thank you so much

Krzemo
January 28th, 2005, 06:43 AM
It depends on locking hint U use. If U want that noone can read rows after U do "SELECT" then U have to use exclusive locking (XLOCK) hint.


Best regards,
Krzemo.