- Try Catch Demo
-- Note: Severity greater than 10 only is caught in Catch block
create procedure dbo.ErrorDetails
as
select
ERROR_NUMBER() AS ErrorNumber,
ERROR_SEVERITY() AS ErrorSeverity,
ERROR_STATE() AS ErrorState,
ERROR_PROCEDURE() AS ErrorProcedure,
ERROR_LINE() AS ErrorLine,
ERROR_MESSAGE() AS ErrorMessage;
GO
-- Execute the following
begin try
select getdate()
select 1/0
end try
begin catch
select error_message()
exec ErrorDetails
end catch;
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment