xxxxxxxxxx
CREATE FUNCTION <function_name> (<@paramater_name> <datatype>)
RETURNS <return_datatype>
AS
BEGIN
<DML statements>
RETURN expression
END
xxxxxxxxxx
ALTER FUNCTION east_or_west (
@long DECIMAL(9,6)
)
RETURNS CHAR(4) AS
BEGIN
DECLARE @return_value CHAR(4);
SET @return_value = 'same';
IF (@long > 0.00) SET @return_value = 'east';
IF (@long < 0.00) SET @return_value = 'west';
RETURN @return_value
END;
SELECT dbo.east_or_west(0) AS argument_0, dbo.east_or_west(-1) AS argument_minus_1, dbo.east_or_west(1) AS argument_plus_1;