• Thanks everyone. I did find what the issue was, and that's because I was running the procedure after a SET FMTLONLY ON, which forced every if statement to run. Although at run time the procedure is protected against recursion, the FMTONLY caused SQL Server to "think" it had recursion.

    Thanks everyone for the responses.