首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

如何在事物中获取未提交前的数据

2013-01-11 
怎么在事物中获取未提交前的数据if OBJECT_ID(testtb) is not nulldrop table testtbgocreate table tes

怎么在事物中获取未提交前的数据


if OBJECT_ID('testtb') is not null
drop table testtb
go

create table testtb
(id int identity(1,1) not null,
 iQty dec(18,2),
 Version timestamp
 )
 
insert into testtb (iQty)
select 12


begin tran 
select CAST(Version as bigint) from testtb 
where id=1 
update testtb set iQty=12 where id=1
select CAST(Version as bigint) from testtb 
where id=1 
commit tran 


我想在第二次查询到的版本号 与第一次查询到版本号一样,请问怎么设置查询呢?
[解决办法]
这个不行,只要改变过就会递增版本,事务无效

可以自定义版本,如用触发器等

热点排行