• BenWard (12/17/2012)


    Hello,

    I have a database used for reports that has a bunch of scalar functions on it that generate assorted record counts etc. Scalar functions we know are inefficient but suit our purposes as speed is not the most important thing on this particular server. Scalar functions allow for easy code re-use so we can guarantee that whatever report is calling the function they will all get the same counts/results without faffing about too much.

    Not trying to beat you up, but that is still no excuse to use a Scalar function. If not on this database since you said performance is not important (how rare is that :-D) this technique for using an Inline Table-valued function instead of a logically equivalent Scalar-valued function may come in handy for you down the line. All it requires is a little shift in thinking on how you write your functions and the queries that use them:

    Inline Scalar Functions by Itzik Ben-Gan

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato