SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Site Related Forums
 Article Discussion
 scalar function for percentage returns NULL
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

a4u6178
Starting Member

India
11 Posts

Posted - 03/12/2012 :  06:09:51  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

Germany
8765 Posts

Posted - 03/12/2012 :  06:43:12  Show Profile  Visit webfred's Homepage  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000