用户 1:
begin tran
select * from items with(nolock);
insert into orders (odate) values(getdate());
insert into OrderData values((select max(orderid) from Orders with(nolock)),1,1);
update Items set qih=qih-1 where item_id=1;
select * from OrderData where oid=(select max(orderid) from Orders with(nolock));
insert into OrderData values((select max(orderid) from Orders with(nolock)),2,1);
update Items set qih=qih-1 where item_id=2;
select * from OrderData where oid=(select max(orderid) from Orders with(nolock));
commit tran;
用户 2:
begin tran
select * from items with(nolock);
insert into orders (odate) values(getdate());
insert into OrderData values((select max(orderid) from Orders with(nolock)),1,1);//in here waiting this user
提交 user1 后。用户 2 的最后一条语句正在执行。
但我想执行这个用户 2 的最后一条语句而不是等待。我该怎么做。
请帮我。