1、HOLDLOCK
其他事务可以读取,但不能更新删除
BEGIN TRAN
SELECT * FROM ceb_Area WITH(ROWLOCK,HOLDLOCK) where ID=1--行锁
SELECT * FROM ceb_Area WITH(TABLOCK,HOLDLOCK) where ID=1--表锁
WAITFOR DELAY '00:00:10'
COMMIT TRAN;
2、TABLOCKX
其他事务不能读取表,更新和删除
BEGIN TRAN
SELECT COUNT(0) FROM ceb_P_Loan WITH(TABLOCKX) WHERE DATEDIFF(d,CreateTime,'2013-12-2')=0
WAITFOR DELAY '00:00:10'
COMMIT TRAN;