USE <Database_Name>
GO
IF OBJECT_ID(N'udf__Minimum') IS NOT NULL
DROP FUNCTION [udf__Minimum]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- *****************************************************************************
-- Name : udf__Minimum
-- Author : Chandra Gunawan
-- Date : 25-Nov-11
-- Description : Returns the minimum value of 2 input value
-- Parameters :
-- @pValue1 money First value to compare
-- @pValue2 money Second value to compare
--
-- Usage Sample :
-- -------------------------------------------------
-- SELECT dbo.udf__Minimum(200, 100)
-- --> Result: 100
-- -------------------------------------------------
--
-- Maintenance Log
-- =============================================================================
-- Date ID Description
-- -----------------------------------------------------------------------------
-- 25-Nov-08 chg Initial Revision
-- *****************************************************************************
CREATE FUNCTION udf__Minimum
(
@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__Minimum TO public
GO
No comments:
Post a Comment