欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

事务

程序员文章站 2022-05-12 21:29:16
...
begin transaction
declare @sumError int=0
update bank set balance=balance-1000 where cid='3'
set @[email protected][email protected]@ERROR
update bank set balance=balance+1000 where cid=1
SET @[email protected][email protected]@ERROR
if(@sumError<>0)
begin
	rollback transaction
end
else
begin
	commit transaction
end