/****************************************************************************************************************
-- Delete the contents of the measurement hierarchy tables in preparation for re-loading them. 
****************************************************************************************************************/
TRUNCATE TABLE RPT_MeasurementHierarchyNodes
GO
DELETE FROM RPT_MeasurementHierarchy
GO

--Creating [dbo].[GetMeasurementID]'
if exists (select * from sysobjects where name='GetMeasurementID' and  xtype = 'FN')
DROP FUNCTION GetMeasurementID
GO
--*****************************************************************************
/* ##FND_BEGIN dbo.GetMeasurementID ^^
Function that returns the id that corresponds to the specified standard name. 
If it cannot find the name an ID of zero is returned. 

<P><I>For more information, follow the Source link at the top of the page.</I></P>
##FND_END */
--
-- $id:$
-- 
--*****************************************************************************
CREATE FUNCTION dbo.GetMeasurementID (@aStandardName NVARCHAR(400))
RETURNS SMALLINT
AS
BEGIN
	DECLARE @id SMALLINT
	SET @id = NULL
	SELECT 
		@id = id
	FROM 
		dbo.MM_MeasurementMap
	WHERE 
		StandardName = @aStandardName
	IF(@id IS NULL)
	BEGIN
		SET @id = 0
	END
	RETURN @id
END
GO
