I'm using the SMALLMONEY data type. I have a function that uses a string value passed from VB.NET to add the string to the SMALLMONEY value and return the result as SMALLLMONEY. The following function works:
CREATE FUNCTION dbo.AddMoney
@ORIGINALVALUE AS SMALLMONEY, --The original Value to be added to
@ADDAMOUNT AS VARCHAR(10) --The value to be added
DECLARE @RETURNAMOUNT AS SMALLMONEY
SET @RETURNAMOUNT = CAST(@ADDAMOUNT AS SMALLMONEY)
SET @RETURNAMOUNT = @RETURNAMOUNT + @ORIGINALVALUE
My question is: I need to calculate a percentage of a SMALLMONEY value and return the result as a SMALLLMONEY. So I need to pass in the Price to amend, and the percentage to calculate ie (17.5% TAX). What would be the best types to pass in to the function and how would I manage the conversions to get an accurate result?