Eugene Elutin (5/23/2014)
... SQL Server doesn't really support code reuse in a useful way...
I would say that it's very arguable statement...
😉
I'd take Grant's side in any such argument.
In general, it's a trade off (in SQL) between code reusability and performance. Yes, there are way to write code like this so that it's reusable in a myriad of possible queries. The performance will suffer badly as a result.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability