Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Site Related Forums
 Article Discussion
 scalar function for percentage returns NULL

Author  Topic 

a4u6178
Starting Member

11 Posts

Posted - 2012-03-12 : 06:09:51
Hi all,

I am trying to calculate percentage value using scalar function it returns NULL result

Here is the function:

alter Function calculateComission
(@discount nvarchar(25),
@regFEE varchar(25),
@comissionPercentage nvarchar(25))
RETURNS varchar(25)
AS
BEGIN

DECLARE @dicountedREGFEE DECIMAL,@comission DECIMAL;

set @dicountedREGFEE=((cast(@discount as DECIMAL(18,2)) *cast(@regFEE as DECIMAL(18,2)))/100);
set @comission=((@dicountedREGFEE * cast(@comission as DECIMAL(18,4)))/100);

return @comission
END

calling function:

DECLARE @result DECIMAL
set @result=select dbo.calculateComission('20','29.01','4.5') as result
print @result

Thanks & Regards,

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2012-03-12 : 06:43:12
duplicate post: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=172344


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -