-- 建测试表
create table zc
(id int not null,
col1 char(4000),
col2 char(4000)
constraint pk_zc primary key clustered(id)
)
insert into zc
select 1,'aaa','bbb' union all
select 2,'ccc','ddd' union all
select 3,'eee','fff' union all
select 4,'ggg','hhh' union all
select 5,'iii','jjj'
-- 在连线1执行
begin tran
--[查询某条数据]
select * from zc (xlock) where id=2
-- 此时连线2执行 select * from zc (xlock) where id=2 会出现等待.
--[其它操作]
update zc set col1='sss' where id=4
commit tran
-- 此时连线2执行 select * from zc (xlock) where id=2 结果返回.