【发布时间】:2012-01-27 16:13:04
【问题描述】:
用户 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 的最后一条语句而不是等待。我该怎么做。
请帮帮我。
【问题讨论】:
标签: c# sql concurrency transactions nolock