use 数据库 select db_name(a.dbid) as 数据库名, req_mode as 锁类型, object_name(rsc_objid) as 表名, * from master..sysprocesses a,master..syslockinfo b where b.req_spid=a.spid
是共享锁,如果改成排它锁,就不会锁多个了第一個事務 begin tran select * from iepb00h with(xlock) where od_id='GBP' waitfor delay '00:00:20' commit tran 第二個事務 select * from iepb00h (rowlock) where od_id='GBP'
select
db_name(a.dbid) as 数据库名,
req_mode as 锁类型,
object_name(rsc_objid) as 表名,
*
from
master..sysprocesses a,master..syslockinfo b
where b.req_spid=a.spid
指定通常采用页锁或表锁时,采用行锁。在从 SNAPSHOT 隔离级别操作的事务中指定时,除非将 ROWLOCK 与需要锁的其他表提示(例如,UPDLOCK 和 HOLDLOCK)组合,否则不会取得行锁。
begin tran
select * from iepb00h with(xlock) where od_id='GBP' waitfor delay '00:00:20'
commit tran 第二個事務
select * from iepb00h (rowlock) where od_id='GBP'