[英]The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION, but still getting an error
Simple query: Before the UPDATE, the value of EffectiveStartDt is NULL After the UPDATE and the ROLLBACK, I want it to go back to NULL简单查询:UPDATE前EffectiveStartDt的值为NULL UPDATE和ROLLBACK后,我想让它回到NULL
begin tran t1
update MasterPayor
set EffectiveStartDt = '2020-09-17'
where MasterPayorId = 1
commit
rollback tran t1
I have defined the transactions, but I'm still getting the Rollback error我已经定义了事务,但我仍然收到回滚错误
The COMMIT
commits the update to the Database and clears the transaction begun with the matching BEGIN TRAN
, hence the error when you try to rollback. COMMIT
将更新提交到数据库并清除以匹配的BEGIN TRAN
开始的事务,因此在您尝试回滚时出错。 If you want to ROLLBACK use the ROLLBACK
without the COMMIT:如果要回滚,请使用不带 COMMIT 的
ROLLBACK
:
begin tran t1
update MasterPayor
set EffectiveStartDt = '2020-09-17'
where MasterPayorId = 1
rollback tran t1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.