begin try
begin transaction
select 100/0 ---0 不能为除数
commit transaction
print 'transaction committed'
end try
begin catch
rollback
print 'transaction rolled back'
select ERROR_NUMBER() as ErrorNumeber,
ERROR_SEVERITY() as ErrorSeverity,
ERROR_STATE() as ErrorState,
ERROR_MESSAGE() as ErrorMessage;
end catch
go
要捕获什么异常?用try catch