I need to return error details in calling application using SQL stored procedure output parameter. If I use throw in catch block that time in case if procedure not execute successfully then output parameter will not not set with error details and if I ignore throw then it will work.
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER proc [dbo].[pt44]
(
@a int,
@b int,
@Msg varchar(2000) output
)
as
begin
DECLARE @c int
begin try
set @c= (@a+@b)
print 'C Value :' +@c--cast(@c as varchar(20)) error is here
end try
begin catch
set @Msg='Error No. '+CAST(ERROR_NUMBER() AS VARCHAR(200))+'Error Line. '+CAST(ERROR_LINE() AS VARCHAR(200))+' Error Message.'+ERROR_MESSAGE()
--;throw
end catch
end
Please tell me the best way how I can pass error to calling application and also want to use throw in SQL Server catch block.