Yes, the scalar is called several times, as you encoded it. One way to make it work is to wrap it in a subquery:
SELECT t.[days] + t.[DayRate], t.[days] / t.[WorkDays] FROM ( SELECT [dbo].[fn_Days](@Account) as days, u.[DayRate], u.[WorkDays] FROM [dbo].[tblUnit] u) as t
This way fn_Days is only called once per line, not twice, or six times, as you mentioned.
Hope this helps.
source share