I have a stored procedure which can return a error this example its going to return error always
create proc regresaerror
as
begin
raiserror 51001 'Error al borrar los precios especiales'
end
declare @error varchar(max)
set @error=''
begin try
set @error=exec regresaerror
end try
begin catch
end catch
I tried it (because I need insert this error in a temporary table) but that block code get this error
Msg 156, Level 15, State 1, Line 4
Incorrect syntax near the keyword ‘exec’.
Stored procedure couldn’t be updated for add a output variable
Then how can I catch the error?
1st solution:
Here is link to MSDN.
2nd solution: