A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
In my case it's occurring with: Product: Microsoft SQL Server Developer (64-bit) OS: Windows 10 Pro (10.0) Version: 16.0.1105.1
This is the release version (more or less) of SQL 2022. The more recent cumulative update is CU which you should download and install. You may be running into a bug that has been fixed.
There was a major change with regards to scalar user-defined functions in SQL 2019: SQL Server now attempts to inline them. Initially, there were not that many features that blocked inlining, but the list has grown over time of the simple reason that the inlining did not always produce correct results. I believe that there has been fixes to inlining even after SQL 2022 has come out, so that's why I want you to try CU10.
To verify that this is an issue with inlining, you can add WITH INLINE = OFF to the header of you procedure:
ALTER function [dbo].[fnSchedRecurGetNextDate] (@CustomerId uniqueidentifier) returns varchar(10) WITH INLINE = OFF
as begin
I did not quite follow your StackOverflow post, but it seems that you have a couple of procedures that nest. You may have to disable inlining with more than one of them.