事务
sql-事务
开始执行事务:begin transaction
提交事务:commit transaction
回滚:rollback transaction
栗子:
begin transaction
DECLARE @tran_error int; SET @tran_error = 0;
BEGIN TRY
update student set age=23 where name='小哥哥'
End try
BEGIN CATCH SET @tran_error = @tran_error + 1
END CATCH
IF(@tran_error > 0) BEGIN rollback transaction END ELSE BEGIN commit transaction END