ESAT ERKEC (3/19/2013)
CREATE TABLE [dbo].[TESTROWLOCK](
[ID] [int] NULL,
[NAME] [varchar](100) NULL,
[SURNAME] [varchar](200) NULL
) ON [PRIMARY]
I m trying
SELECT ID FROM TESTROWLOCK WITH(ROWLOCK) WHERE ID=2
SELECT ID FROM TESTROWLOCK WHERE ID=2
I want to ask that tab-2 select is give result but tab-1 is not commited why rowlock hint does not lock that rows
ROWLOCK just opens a shared lock which is compatible with other shared locks.
For locking a row based on a SELECT you would need to ask for WITH (UPDLOCK, TABLOCK) which takes an exclusive table lock, or you could use the SERIALIZABLE isolation level in the window with your transaction. Both options have high safety for your rows, but are very low on concurrency allowances.
__________________________________________________________________________________________________There are no special teachers of virtue, because virtue is taught by the whole community. --Plato