Finding factorial in Sql

Bageshkumarbagi
Posted by Bageshkumarbagi under Sql Server category on | Points: 40 | Views : 740
Hi,

DECLARE @num int,@fact int,@f int
SET @num=5
SET @f=@num
SET @fact=1
WHILE (@num>0)
BEGIN
SET @fact=@num * @fact
SET @num=@num -1
END
PRINT @fact

Comments or Responses

Login to post response