SQL2005 异常处理机制(Begin try Begin Catch)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SQL2005 异常处理机制(Begin try Begin Catch)相关的知识,希望对你有一定的参考价值。
--语法
begin try
--SQL
end try
begin catch
--sql (处理出错动作)
end catch
begin try
--SQL
end try
begin catch
--sql (处理出错动作)
end catch
begin try
select 2/0
end try
begin catch
select error_number() as error_number ,
error_message() as error_message,
error_state() as error_state,
error_severity() as error_severity
print error_number()+ error_severity() +error_state()+error_procedure()+error_line()+error_message()
end catch
select 2/0
end try
begin catch
select error_number() as error_number ,
error_message() as error_message,
error_state() as error_state,
error_severity() as error_severity
print error_number()+ error_severity() +error_state()+error_procedure()+error_line()+error_message()
end catch
以上是关于SQL2005 异常处理机制(Begin try Begin Catch)的主要内容,如果未能解决你的问题,请参考以下文章
T-SQL编程中的异常处理-异常捕获(try catch)与抛出异常(throw)