sqlserver 添加事务执行 语句

begin tran

update 表
set = ..

if @@error = 0 
   commit tran
else
   rollback tran
go

例如:

begin tran
update  [GTOW].[dbo].[ContactsInfo] set Telephone='5632或5822' where state=0    and Id=4
if @@error = 0 
   commit tran
else
   rollback tran
go 
 

猜你喜欢

转载自blog.csdn.net/xulong5000/article/details/115003343