Self Calculation In SQL Server

In this blog, we can calculate self value calculation in SQL 

Ex. 14=5 (1+4=5), 88=16 (8+8=16) , 65=11 (6+5=11);

Step 1

Declare below Local parameter

Declare @Number int = 14;  -- Declare local parameter
Declare @Mod int = 0;
Declare @Sum int =0;

Step 2

Declare while loop for self calculation by using mod & % (like below )

while (@Number >0)
Begin

Set @Mod = @Number%10;
Set @Number = @Number/10;
Set @Sum = @Sum+@Mod;

End

Select @Sum As SelfSumOF

Output

Self Calculation in SQL Server

Thank you for reading my blog also visit my other blogs & Youtube Videos (TechFullStack7 - YouTube)