sqlserver add transaction execution statement

begin tran

update 表
set = ..

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

 

E.g:

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 
 

Guess you like

Origin blog.csdn.net/xulong5000/article/details/115003343