Is there a method in T-SQL to see if error occurred in Stored Procedure, without the use of @Output or try catch?
We have a lot of legacy code 200+ stored procedures. I have seen @Output method and try catch, however we would have to refactor legacy code, which may break. Just curious, if there is a way to catch error without changing old code.
declare @TestErrorFlag bit -- or can be int or varchar(255)
-- trying to do something similar to this
set @TestErrorFlag = if error(exec dbo.testprocedure)
Trying to store in some type of indicator variable
@TestErrorFlag = 1 if procedure succeeds,
@TestErrorFlag = 0 if procedure fails
if error(exec sp)
is the same astry exec sp catch
. My SP returns 0 if everything went well and other value, usually a negative value, if went wrong.RETURN <int>;
where<int> != 0
, or...?