I want to create a function in sql server that return the cost of product according to its price prefix. Price prefix either is"+" or "-".
MY code is:
CREATE FUNCTION calculateOptionCost ( @product_price Decimal, @optionPrice Decimal, @action varchar )
RETURNS Decimal
AS
BEGIN
IF (@action == '+')
RETURN (@product_price + @optionPrice);
IF (@action == '-')
RETURN (@product_price - @optionPrice);
END
GO
In parameter, I have passed it's parent product price, its price and its price prefix. But when i execute this code the system give error as:
The last statement included within function must be a return statement.