Punching
Thanks for watching!
Going Further
If this is the kind of SQL Server stuff you love learning about, you’ll love my training. Blog readers get 25% off the Everything Bundle — over 100 hours of performance tuning content. Need hands-on help? I offer consulting engagements from targeted investigations to ongoing retainers. Want a quick sanity check before committing to a full engagement? Schedule a call — no commitment required.
I suspect the reason people make the choices they do with UDFs is because of the lack of something like an #INCLUDE directive. It would allow you to create, say, a CTE once and use it in many stored procedures. Granted, I am ignoring the syntax difficulties that would pose (if there are CTEs already in the code where does the new one slot in, et cetera). The fact that SQL is primarily an interpreted language (except for in-memory objects, of course) seems to make it an ideal candidate for library dynamism.
Sure, none of this has anything to do with why the scalar UDF cannot be inlined. However, solving the issue of DRY development by instead trying to improve UDF execution after the fact by inlining seems like MS solving the wrong end of the problem.