Eugene Elutin (9/21/2012)
Another way in c# :
public static int SumDigits(int Input) { return Input.ToString().Sum(c => c - '0'); }
I think that would be slower (and it also requires a higher version of .NET - the function I posted works on SQL Server 2005-2012).
Paul White
SQLPerformance.com
SQLkiwi blog
@SQL_Kiwi