Common Table Expressions Are Useful For Rewriting Scalar Functions In SQL Server

Punching



Thanks for watching!

Going Further


If this is the kind of SQL Server stuff you love learning about, you’ll love my training. I’m offering a 75% discount to my blog readers if you click from here. I’m also available for consulting if you just don’t have time for that and need to solve performance problems quickly.



One thought on “Common Table Expressions Are Useful For Rewriting Scalar Functions In SQL Server

  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.

Comments are closed.