If you have 300,000 rows, the UDF will be called 300,000 times if you defined a scalar UDF.
More info:
User Defined Functions and Performance
Using a table valued function could improve performance.
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP