CTEs Are Useful For Rewriting Scalar Functions


One thought on “CTEs Are Useful For Rewriting Scalar Functions

  1. 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.

Leave a Reply

Your email address will not be published. Required fields are marked *