USE $(DATA_BASE_NAME);
GO

DROP VIEW [drtrpt].[DartRequestDataSource]
GO

/****** Object:  View [drtrpt].[DartRequestDataSource]    Script Date: 2/24/2016 1:58:21 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE view [drtrpt].[DartRequestDataSource]
as

select req.ActivityID as ResearchStudyID
              , req.ID as RequestID
              , req.TrackIngNumber
              , ds.ID as DataSourceID 
              , ds.Name as DataSource
              , ds.description as DataSourceDescription
              , ds.DomainName
from hib.request req
       inner join hib.ResearchStudyDataSource rsds on req.ID = rsds.researchstudyid
       inner join hib.DataSource ds on rsds.DataSourceID = ds.ID
--order by TrackingNumber, DataSourceID



GO

