zoukankan      html  css  js  c++  java
  • Sql Server 中事务(begin tran/commit tran/rollback tran)的用法

     1     ALTER PROCEDURE [dbo].[Proc_Test_commit1] 
     2     @result int output, --成功 1; 失败 0
     3     @message nvarchar(20) output
     4 AS
     5 BEGIN
     6     SET NOCOUNT ON
     7      
     8 begin try 
     9       begin tran yy 
    10         insert into Test_Commit (b) values (3)
    11  
    12         insert into Test_Commit (a,b) values (1,3)
    13         set @result=1
    14       commit tran yy            
    15                   end try   
    16 begin catch
    17         set @message= ERROR_MESSAGE() 
    18         set @result=0
    19         rollback tran yy        
    20         --insert into SYS_Proc_Message([Message]) values(ERROR_MESSAGE())
    21         print ERROR_MESSAGE()
    22 end catch 
    23      
    24     SET NOCOUNT OFF;  
    25      
    26      
    27 END
  • 相关阅读:
    Python day thirteen
    Python day twelve
    Python day eleven
    Python day ten
    Python day nine
    Python day eight
    Python day seven
    Python day six
    Python day five
    Python day four
  • 原文地址:https://www.cnblogs.com/hongmaju/p/4460278.html
Copyright © 2011-2022 走看看