I have tried the CAST you showed above and it works fine when I use a SELECT statement to return the value.
However, since I am using a user defined function I cannot use the SELECT statement to return a value. I have to use the RETURN statement.
That is what returns the value:
Set @returnVal = ISNULL(CAST(@calculatedRate AS DECIMAL(15,2)), -1)
This is how I am testing it in query analyser:
select dbo.GetRate( 40, 423, 1, 1, 540, 0, 1)
Could you please shed some light?