• Unfortunately, your return string is not quite big enough:

    SELECT dbo.fnSpellInteger ( 1999999999 )

    Gives me:

    One Billion Nine Hundred Ninety-Nine Million Nine Hundred Ninety-Nine Thousand Nine Hundred Ninety-

    The function would be better written to return VARCAHR(MAX) - or at least VARCHAR(112):

    SELECT LEN(dbo.fnSpellInteger ( 1777777000 ) + ' ' + dbo.fnSpellInteger ( 777 ))

    Of course, it could easily be extended to BIGINT as well 🙂