Need to lock a record after I select it and unlock it (even without updating).
I also need to check if record is lock.
Been googling this for quite some time now, found some articles on locking row from table but not from a view.
When I implement on my view, did not seem to work.
BEGIN TRAN
SELECT * FROM myTable WITH (UPDLOCK,READPAST)
WHERE myID = someValue
COMMIT TRAN
--CHECK IF ID IS LOCKED
SELECT myID FROM myTable WITH(NOLOCK)
WHERE myID NOT IN
(
SELECT myID FROM myTable WITH(READPAST)
)
Tried different combination of (UPDLOCK,READPAST) i.e HOLDLOCK, ETC..
Any Help will be greatly appreciated.
I also need to check if record is lock.
Been googling this for quite some time now, found some articles on locking row from table but not from a view.
When I implement on my view, did not seem to work.
BEGIN TRAN
SELECT * FROM myTable WITH (UPDLOCK,READPAST)
WHERE myID = someValue
COMMIT TRAN
--CHECK IF ID IS LOCKED
SELECT myID FROM myTable WITH(NOLOCK)
WHERE myID NOT IN
(
SELECT myID FROM myTable WITH(READPAST)
)
Tried different combination of (UPDLOCK,READPAST) i.e HOLDLOCK, ETC..
Any Help will be greatly appreciated.