News for hackers. Stuff that matters.
Re:SQL Notebook by ak39 on Wednesday May 10, 2017 @02:56AM (#14306363)
Have you used T-SQL's "CROSS APPLY" or "OUTER APPLY" in conjunction with encapsulated views or table-valued functions?

You might want to have a look at that as a significant enabler of code reuse on SQL Server.

(On PgSQL is LATERAL JOIN)

(Ps: you should try to replace SCALAR functions with SET-BASED logic. These can easily be ringfenced into TVF)

Re:SQL Notebook by Pxtl on Wednesday May 10, 2017 @07:28AM (#14307386)
TVFs are intensely verbose to use compared to the corresponding SVF for a single column. Cross Apply will destroy your performance. I'm venting because I've watched clean, legible code get destroyed into soup of a zillion tiny joins and endless repeated boilerplate for performance improvement by this misfeature.