create table T_TestTrans(ID int)A程序:
begin tran
insert into T_TestTrans values(2)
A程序后面继续执行很多SQL才提交事务,在A程序提交事务之前B程序开始访问
select * from T_TestTrans 结果B程序需要等到A程序事务提交之后才能返回查询结果
我想做到B程序立即返回执行结果,不用等到A程序提交事务之后才返回,但不包含A程序在事务中提交(更新、插入、删除)的数据 ,请教怎样才能实现
begin tran
insert into T_TestTrans values(2)
A程序后面继续执行很多SQL才提交事务,在A程序提交事务之前B程序开始访问
select * from T_TestTrans 结果B程序需要等到A程序事务提交之后才能返回查询结果
我想做到B程序立即返回执行结果,不用等到A程序提交事务之后才返回,但不包含A程序在事务中提交(更新、插入、删除)的数据 ,请教怎样才能实现
---------------------
那没办法了 只有这个了 nolock 是包含脏数据的 你都锁定了 怎么看啊
insert into T_TestTrans(……,status) values(2,'中') ……
update T_TestTrans set status='是' where status='中'
commit
A程序后面继续执行很多SQL才提交事务,在A程序提交事务之前B程序开始访问
select * from T_TestTrans with (nolock) where status='是'
select * from T_TestTrans with (readpast)