sql 数据库 try --- catch用法

begin try
select 5/0
end try
begin catch
select
ERROR_NUMBER()     as     N'错误号',
ERROR_SEVERITY()     as     N'错误严重等级',
ERROR_STATE()     as     N'错误状态',
ERROR_PROCEDURE()    as     N'错误的过程名称',
ERROR_LINE()     as     N'产生错误的行号',
ERROR_MESSAGE()     as     N'错误消息文本'
end catch
go

 

posted on 2014-07-14 20:48  yl1993  阅读(352)  评论(0编辑  收藏  举报