• Nice article. Very informative.

    Interestingly enough, I just found out a couple of months ago in reading the articles on set-based programming versus procedural programming on Code Project http://www.codeproject.com/Articles/34142/Understanding-Set-based-and-Procedural-approaches and Subho on .Net http://www.shubho.net/2009/03/understanding-set-based-and-procedural_09.html that the use of a function in a select clause results in RBAR processing. They pointed that in a million row table you would be calling the function a million times. It makes perfect sense, though I had never thought about it that way, even while avoiding Cursors like the plague. They recommended that the use of correllated subqueries and JOINS and even While loops would avoid this performance hit. Now I see that using a table valued function with a cross apply will work as well. So I will be adding this to my list of tools.

    Thank you also for pointing out the issues with set statistics time ON. I will be certain not to use it from now on.