USE <Database_Name>
GO
IF OBJECT_ID(N'udf__Maximum') IS NOT NULL
DROP FUNCTION [udf__Maximum]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- *****************************************************************************
-- Name : udf__Maximum
-- Author : Chandra Gunawan
-- Date : 25-Nov-11
-- Description : Returns the maximum value of 2 input value
-- Parameters :
-- @pValue1 money First value to compare
-- @pValue2 money Second value to compare
--
-- Usage Sample :
-- -------------------------------------------------
-- SELECT dbo.udf__Maximum(200, 100)
-- --> Result: 200
-- -------------------------------------------------
--
-- Maintenance Log
-- =============================================================================
-- Date ID Description
-- -----------------------------------------------------------------------------
-- 25-Nov-08 chg Initial Revision
-- *****************************************************************************
CREATE FUNCTION udf__Maximum
(
@pValue1 AS money,
@pValue2 AS money
)
RETURNS money
AS
BEGIN
RETURN (CASE
WHEN @pValue1 IS NULL OR @pValue2 IS NULL THEN NULL
WHEN @pValue1 > @pValue2 THEN @pValue1
ELSE @pValue2
END)
END
GO
GRANT EXECUTE ON udf__Maximum TO public
GO
No comments:
Post a Comment