本文介绍了用户定义的功能练习的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要创建一个用户定义的函数来查找简单的兴趣(本金金额为否).年份和费率作为参数.
下一个是创建用户定义的函数以查找数字的阶乘.
帮帮我...
I need to create a user defined function to find simple Interest, with Principal amount, no. of years and rate as parameters.
The next one is to create a user defined function to find the factorial of a number.
Help me out...
推荐答案
create FUNCTION dbo.Factorial ( @iNumber bigint )
RETURNS INT
AS
BEGIN
DECLARE @i bigint
IF @iNumber <= 1
SET @i = 1
ELSE
SET @i = @iNumber * dbo.Factorial( @iNumber - 1 )
RETURN (@i)
END
declare @int bigint
exec @int= dbo.Factorial 12
select @int
这篇关于用户定义的功能练习的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!