抛出错误的例子
begin try begin tran tran1 select 1/0 commit tran tran1 end try begin catch --抛出错误 declare @errMsg varchar(max) = Convert(varchar(50),error_number()) +':'+error_message() +'错误位置:'+Convert(varchar(50),error_line()); RAISERROR ('{ code:""%s"",msg:""%s""}',16,16,'1002',@errMsg); --回滚 rollback tran tran1 end catch