Example 1
DECLARE @returnValue INT,
@ErrorCode INT
EXEC @returnValue = dbo.uspUserSP
SET @ErrorCode = @@ERROR;
IF (@ErrorCode <> 0 OR @returnValue <> 0)
BEGIN
-- Error Handling
RAISERROR('Process Failed, ERROR CODE:%d',16,1,@ErrorCode);
END
Example 2
EXEC @ExecStatus = dbo.uspName01;
IF @ExecStatus <> 0 RAISERROR('Failed on EXEC dbo.uspName01', 14, 100);
Sources:
Comments