After calling a stored procedure from within a stored procedure, check the return value of the called procedure. If the return value is non-zero, the stored procedure returned an error (assuming the procedure follows that standard).
If procedure A calls procedure B and procedure B has an error, procedure B should call RAISERROR and return a non-zero value. Procedure A can call RAISERROR and then return a non-zero value or it can just return the non-zero value without calling RAISERROR.
Exceptions:
Method 1:
CREATE PROCEDURE dbo.RGExampleExecCall (
...
EXEC @rtnVal = dbo.RGUpdateUserLastName
...
IF @rtnVal <> 0 BEGIN
EXEC dbo.TagValueList @list OUTPUT, 'UserID', @UserID, 'LastName', @LastName
RAISERROR(990008, 16, 1, @rtnVal, @spName, 'RGUpdateUserLastName', @list)
RETURN(@rtnVal)
END
...
END
Method 2:
CREATE PROCEDURE dbo.RGExampleExecCall (
...
EXEC @rtnVal = dbo.RGUpdateUserLastName
...
IF @rtnVal <> 0 BEGIN
RETURN(@rtnVal)
END
...
END