复制代码 代码如下:
begin try
…
…
end try
begin catch
declare @errormessage nvarchar(4000);
declare @errorseverity int;
declare @errorstate int;
select
@errormessage = error_message(),
@errorseverity = error_severity(),
@errorstate = error_state();
raiserror (@errormessage, — message text.
@errorseverity, — severity.
@errorstate — state.
);
end catch;