CREATE PROCEDURE usp_CheckAmstrongNumber
DECLARE @InputNumber INT
AS
BEGIN


SET NOCOUNT ON;

DECLARE @IncNo INT
DECLARE @TotalCnt INT
DECLARE @AmstrongNo INT


SET @AmstrongNo = @InputNumber
SET @IncNo = 0
SET @TotalCnt = 0


WHILE (LEN(@AmstrongNo) >= @IncNo)
BEGIN


SET @TotalCnt = @TotalCnt + POWER(@InputNumber % 10, LEN(@AmstrongNo))
SET @InputNumber = @InputNumber / 10
SET @IncNo = @IncNo + 1


END

IF(@AmstrongNo = @TotalCnt)
SELECT 'Amstrong Number'
ELSE
SELECT 'Not a Amstrong Number'


END
GO