As the other respondants say, I don't think you can do exactly what you ask for.
However I think you could make a reasonable approximation using default parameters. If you know a reasonable upper limit, the you could define a function something like this:
--Edit
Turns out you can't have default values on a UDF. Or rather you can define them, but you still have to specify the values when calling the function
That means the best you can do is to have function with the maximum number of parameters:
CREATE FUNCTION dbo.fMax
(
@Value1 float,
@Value2 float,
@Value3 float,
@Value4 float
)
RETURNS float
AS
BEGIN
DECLARE @Result float
SELECT @Value1 = COALESCE(@Value1, @Value2, @Value3, @Value4)
SELECT @Value2 = COALESCE(@Value2, @Value1, @Value3, @Value4)
SELECT @Value3 = COALESCE(@Value3, @Value1, @Value2, @Value4)
SELECT @Value4 = COALESCE(@Value4, @Value1, @Value2, @Value3)
SELECT @Result = @Value1
IF (@Value2 > @Result)
SELECT @Result = @Value2
IF (@Value3 > @Result)
SELECT @Result = @Value3
IF (@Value4 > @Result)
SELECT @Result = @Value4
RETURN @Result
END
and call it like this:
SELECT dbo.fMax(1, 5, 4, null)