📜  如何向 SQL 存储过程添加 Try Catch - SQL 代码示例

📅  最后修改于: 2022-03-11 15:04:57.294000             🧑  作者: Mango

代码示例1
CREATE PROCEDURE [dbo].[PL_GEN_PROVN_NO1]        
       @GAD_COMP_CODE  VARCHAR(2) =NULL, 
       @@voucher_no numeric =null output 
       AS         
   BEGIN  

     begin try 
         -- your proc code
     end try

     begin catch
          -- what you want to do in catch
     end catch    
  END -- proc end