Stored procedure using try and catch (throws an exception like divide by zero exp)

Karthikreddy
Posted by Karthikreddy under Sql Server category on | Points: 40 | Views : 1453

create proc [dbo].[sp_tryCatch1]
as
begin
try
select 1/0
end try
begin catch
select ERROR_NUMBER() as ErrorNumber
,ERROR_SEVERITY() as ErrorSeverity
,ERROR_STATE() as ErrorState
,ERROR_PROCEDURE() as ErrorProduce
,ERROR_LINE() as ErrorLine
,ERROR_MESSAGE() as ErorMessge
end catch

Comments or Responses

Login to post response