CREATE FUNCTION dbo.fn_Annualsal ( @p_sal DEC(9,2), @p_comm DEC(5,2))
RETURNS FLOAT
BEGIN
DECLARE @v_ann_sal FLOAT = 0.0, @v_sal DEC(9,2)= COALESCE(@p_sal, 0.0);
SET @v_ann_sal = (@v_sal + @v_sal*COALESCE(@p_comm, 0.0))*12
RETURN @v_ann_sal
END
GO
-- Test
SELECT dbo.fn_Annualsal( 6000, 0.15)
SELECT dbo.fn_Annualsal( 1500, NULL)