USE [ION_Data]
GO

/****** Object:  StoredProcedure [dbo].[IONEEM_GetSourceQuantityPairs]    Script Date: 07/28/2016 15:39:27 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[IONEEM_GetSourceQuantityPairs]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[IONEEM_GetSourceQuantityPairs]
GO

USE [ION_Data]
GO

/****** Object:  StoredProcedure [dbo].[IONEEM_GetSourceQuantityPairs]    Script Date: 07/28/2016 15:39:27 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


--*****************************************************************************
-- PROCEDURE: IONEEM_GetSourceQuantityPairs
--
-- NOTES: Return a list of all source quantity pairs.
--
--*****************************************************************************

CREATE PROCEDURE [dbo].[IONEEM_GetSourceQuantityPairs]
AS

SELECT DISTINCT
	src.ID AS N'SourceID',
	src.DisplayName AS N'SourceName',
	ns.Name AS N'NamespaceName', 
	qt.ID AS N'QuantityID', 
	qt.[Name] AS N'QuantityName' 
FROM         
	dbo.Source src
	JOIN dbo.Namespace ns ON ns.ID = src.NamespaceID
	JOIN dbo.Recorder rec ON src.ID = rec.SourceID
	JOIN dbo.Channel ch ON ch.RecorderID = rec.ID
	JOIN dbo.Quantity qt ON qt.ID = ch.QuantityID

RETURN 0


GO


